Created
November 3, 2012 13:12
-
-
Save brianjriddle/4007353 to your computer and use it in GitHub Desktop.
takes a directory of files and randomizes the names by prefixing them with a number
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
# encoding: utf-8 | |
require "fileutils" | |
include FileUtils::Verbose | |
def usage | |
puts "usage: jruby ORIGINAL_MUSIC_DIR" | |
end | |
if ARGV[0] and File.directory? ARGV[0] | |
jumbled_dir = "jumbled_#{ARGV[0]}" | |
puts "copiying #{ARGV[0]} to jumbled_dir" | |
mkdir_p jumbled_dir | |
files = Dir.glob(ARGV[0] + "/*") | |
files.shuffle.each_with_index do |file, index| | |
cp file.force_encoding("utf-8"), File.join(jumbled_dir, index.to_s + "-" + File.basename(file)) | |
end | |
else | |
usage | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment