Skip to content

Instantly share code, notes, and snippets.

@ahpook
Created May 18, 2011 21:59
Show Gist options
  • Save ahpook/979680 to your computer and use it in GitHub Desktop.
Save ahpook/979680 to your computer and use it in GitHub Desktop.
Not proud of this
Given a directory of MP3s created from FLACs, untagged but correctly named:
1 - Enabl.ed - Modules Fail - odeq2.mp3
02 - Enabl.ed - Modules Fail - Its at this point, where i get drowsy.mp3
03 - Enabl.ed - Modules Fail - Arel Depiq.mp3
04 - Enabl.ed - Modules Fail - Melting in Stereo.mp3
05 - Enabl.ed - Modules Fail - Blowing Ashes.mp3
06 - Enabl.ed - Modules Fail - Make me what they say I am.mp3
07 - Enabl.ed - Modules Fail - exit4.mp3
08 - Enabl.ed - Modules Fail - Vinc Drae5.mp3
09 - Enabl.ed - Modules Fail - Empty Images.mp3
10 - Enabl.ed - Modules Fail - Drowning errors 2.0.mp3
11 - Enabl.ed - Modules Fail - For the last time.mp3
I looped through and pulled the track number off the beginning and the name from the end:
for i in *.mp3; do
echo "$i" | ruby -lane '%x{/opt/local/bin/id3v2 -T "#{$F[0]}/11" -t "#{$F[7..-1].join(" ").gsub(/.mp3$/,"")}" "#{$_}"}'
done
Please suggest better ways!
Remember I need the filename as a string to be the input,
not the file contents (which '-lan' will automatically do if
you just list filenames as positional arguments)!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment