Skip to content

Instantly share code, notes, and snippets.

@danielvlopes
Created March 12, 2009 17:55
Show Gist options
  • Save danielvlopes/78198 to your computer and use it in GitHub Desktop.
Save danielvlopes/78198 to your computer and use it in GitHub Desktop.
# use => ruby rename.rb .jpg thumb_
def generate
files = Dir.entries(".")
count = 1
files.each do |f|
extension = f[/\.[a-z]+$/]
if extension == ARGV[0]
new_name = "#{ARGV[1]}#{count.to_s}#{extension}"
File.rename(f, new_name)
puts "rename #{f} to #{new_name}"
count+=1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment