Skip to content

Instantly share code, notes, and snippets.

@equivalent
Created July 9, 2012 21:32
Show Gist options
  • Save equivalent/3079116 to your computer and use it in GitHub Desktop.
Save equivalent/3079116 to your computer and use it in GitHub Desktop.
Script to rename files in folders (Sketchup animation render)
source 'https://rubygems.org'
gem 'bundler'
gem 'rb-readline'
task :rename do
folder_path = "/media/usbdevise/folder/"
i = 0
Dir.glob(folder_path + "*").sort.each do |f|
i = i + 1
new_name = "%08d" % i
File.rename(f, folder_path + new_name + File.extname(f))
#p folder_path + new_name + File.extname(f)
end
end
@equivalent
Copy link
Author

Just simple script for my girlfriend to rename her rendered animation images... This is when you create animation with Google Sketchup on several scenes. For some reason Sketchup starts naming each scene image 0079.0001.png , insted of 0080.png . Script will just sort named files and rename them in order

  0079.png
  0079.0001.png
  0079.0002.png
  ....
  0079.0282.png
  0079.0282.0001png
  .....

will rename to

 00000001.png
 00000002.png
 00000003.png
 ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment