Created
February 15, 2010 00:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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