Skip to content

Instantly share code, notes, and snippets.

@brianjriddle
Created November 3, 2012 13:12
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 brianjriddle/4007353 to your computer and use it in GitHub Desktop.
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
# 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