Skip to content

Instantly share code, notes, and snippets.

@sundeepgupta
Created September 22, 2014 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sundeepgupta/ef093bfe253c4529c829 to your computer and use it in GitHub Desktop.
Save sundeepgupta/ef093bfe253c4529c829 to your computer and use it in GitHub Desktop.
Rename files in a folder consecutively starting from zero
folder_path = "/Users/sundeepgupta/drive/tmp/sencha icons"
file_paths = Dir.glob(folder_path + "/*")
file_paths.each.with_index do |file_path, idx|
file_extension = File.extname(file_path)
new_file_path = "#{folder_path}/#{idx}#{file_extension}"
File.rename(file_path, new_file_path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment