Skip to content

Instantly share code, notes, and snippets.

@chrismear
Created November 18, 2008 20:55
Show Gist options
  • Save chrismear/26268 to your computer and use it in GitHub Desktop.
Save chrismear/26268 to your computer and use it in GitHub Desktop.
require 'csv'
codes = []
CSV.open("codes.csv", 'r') do |row|
codes[row[1].to_i] = row[0]
end
Dir.chdir 'export'
wd = Dir.getwd
Dir.glob('*') do |dirname|
Dir.chdir(dirname)
Dir.glob('*.png').each do |filename|
number = filename.gsub(/\D/, '').to_i
code = codes[number]
new_filename = "#{code}.png"
puts "Renaming #{filename} to #{new_filename}."
File.rename(filename, new_filename)
end
Dir.chdir(wd)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment