Created
September 22, 2014 02:57
-
-
Save sundeepgupta/ef093bfe253c4529c829 to your computer and use it in GitHub Desktop.
Rename files in a folder consecutively starting from zero
This file contains 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
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