Skip to content

Instantly share code, notes, and snippets.

@aj-justo
Created May 27, 2011 11:23
Show Gist options
  • Save aj-justo/995067 to your computer and use it in GitHub Desktop.
Save aj-justo/995067 to your computer and use it in GitHub Desktop.
Rename images with given pattern
path = 'images/'
imgDir = Dir.new(path)
imgs = imgDir.entries
imgs.each do |i|
if i=='.' or i=='..' then next end
newfile = i.gsub(/([^.]+\.[^.]+\.[^.]+)\.00.jpg/i, '\\1.jpg')
File.rename(path+i, path+newfile)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment