The tumblin´sibling of instant-thinking.de RSS

Just another Website tumblin´through the net.

For not (so much) tumblin´ content please visit instant-thinking.de, which is my regular Weblog.

Search instant-thinkr with Google:

Google Custom Search

Tumblin´ instant-thinkr stats

Please visit the Archives for even more Tumbles.

Apr
5th
Thu
permalink

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.