Monday, April 02, 2007

Tips for massive decoding and tagging files

I recently had a dilemma of wanting to decode and tag my entire live show collection and upload them to my ampache music server. I've fiddled around trying to get ampache play my flac files and was so- so successful. Being that most of my older collection of shows was strictly shorten files, ampache has no means to play them at all. So I sat down and wrote some simple scripts to do all my dirty work of decoding and tagging and another to upload the show via ftp if anyone is interested in using them. Clearly linux / unix only.
To decode shorten, you must use a tool called shnwrapper available from sourceforge.
#!/bin/sh
folder=`pwd | cut -b 20-29`
picture=/home/share/panic.jpg
flac -d *.flac
#shnwrap -x *.shn
oggenc -q 8 *.wav
rm -f *.wav
mkdir $folder
cp *.ogg $folder
cp $picture $folder
cp -r $folder /home/share/wsogg
rm *.ogg
rm -rf $folder
exit 0


Here is a simple script to tag using the id3v2 tool.

#!/bin/bash
FILES=`pwd`/*.ogg
artist=Phish
year=`pwd | cut -b 20-23`
album=Live-Phish" "`pwd | cut -b 22-31`
count=0
for file in $FILES
do
count=`expr $count + 1`
echo "Track $count is [$file]"
id3v2 -T $count -g 17 --year $year -A "$album" -a $artist $file
done


I also have some scripts to determine whether the files are flac or shorten and run the right script on the files as needed. I used these scripts to rip about 250 gigs of music and upload it and works well. The only thing you have to watch is empty spaces in the file names. Im working on script to get rid of that as well. I'm sure ive borrowed code ive seen by googleing so any resemblance, many thanks to the original authors.

No comments: