Skip to content

Instantly share code, notes, and snippets.

@andy318
Created January 10, 2012 05:14
Show Gist options
  • Save andy318/1587134 to your computer and use it in GitHub Desktop.
Save andy318/1587134 to your computer and use it in GitHub Desktop.
Ruby shell code - Find song files that have a single digit track number and prefix 0 to it
#!/usr/bin/env ruby
# Tested in REE 1.8.7. To run from command line, type -
# ruby AddLeadingZeroToSongFile.rb
`ls -1 *.mp3`.split("\n").each do | songfile |
x = /^(\d .*)/.match(songfile)
`mv "#{x.captures[0]}" "0#{x.captures[0]}"` if x
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment