Apr
5th
Thu
5th
Highlighting Ruby
Deleting Whitespace at the End of Filenames (so Windows-Guys can use them too):
#!/usr/bin/ruby
require 'find'
start_dir = "/path/to/your/dir"
Dir.chdir(start_dir)
Find.find(start_dir) do |path|
if /\s+$/.match(File.basename(path))
new_name = (File.basename(path)).sub(/\s+$/,'')
new_name_with_path = (path).sub(/\s+$/,'')
puts "Benenne " + "|" + (File.basename(path)) + "|" + " um in " + "|" + (new_name) + "|"
File.rename((path), (new_name_with_path))
end
end
This nicely colored code only works because of this Hack by Dr Nic.
Brilliant.