Created
December 1, 2018 14:44
-
-
Save angristan/1e42a954a35ac17cd285d2de04097fa1 to your computer and use it in GitHub Desktop.
Ruby script ro rename all of a dir's files with random names
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
directory = 'directory/' | |
new_base_filename_length = 10 | |
Dir.glob(directory + '*').sort.each do |old_filename| | |
new_base_filename = ('a'..'z').to_a.shuffle[0, new_base_filename_length].join | |
new_filename = directory + new_base_filename + File.extname(old_filename) | |
File.rename(old_filename, new_filename) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment