Skip to content

Instantly share code, notes, and snippets.

@cgrusden
Created February 15, 2010 00:26
Show Gist options
  • Save cgrusden/304351 to your computer and use it in GitHub Desktop.
Save cgrusden/304351 to your computer and use it in GitHub Desktop.
Run this script in the same directory as all the .jpg files you want to rename (the format will be: "photo_00001", "photo_00002", etc..). Requires you to install the Ruby framework, but that's it. If you're on a MAC with OS X, it should already be inst
i = 1
Dir.glob("./**/*.jpg").sort {|a,b| File.stat(a).atime <=> File.stat(b).atime}.each do |f|
new_file = "%s-%07d.jpg" % ["photo", i]
puts "Renaming #{f.to_s} to #{new_file}"
File.rename(f.to_s, new_file)
i+=1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment