Filed Under: random
A couple recent projects have required a lot of files - such as images for a gallery or when i’ve converted a video to an image sequence - and i’ve often needed to rename these files. Fortunately for me, I work with a ruby-star (blogroll: Jason Cale) and he gave me this:
Dir.glob(”*”).each {|f| File.rename(f, f.gsub(”pattern”, “replacement”))}
Finds any occurrence of ‘pattern’ in any of the file names in a directory - and replaces it with ‘replacement’. Great times.
Predictably this blog went south, just like all my other attempts. Whatever, I’ve got a new portfolio site, check it out here.