Skip to content

Instantly share code, notes, and snippets.

@youpy
Created May 21, 2009 02:37
Show Gist options
  • Save youpy/115232 to your computer and use it in GitHub Desktop.
Save youpy/115232 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# a/b/c.mp3 -> a/b/a-b-c.mp3
require 'pathname'
require 'fileutils'
require 'enumerator'
include FileUtils::Verbose
src = Pathname.new(ARGV.shift)
dst = src.enum_for(:each_filename).inject([]) do |memo, filename|
memo << filename if filename !~ /^\.+$/
memo
end.join('-')
mv src, src.dirname + dst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment