Monthly Archive for September, 2009

Fixing id3 Tags With a Script in Linux

It took a little work, and a lot of renaming and restructuring folders, but I finally got my id3 tags fixed.  One thing I hate about id3 tags are, after a while, the tags get all messed up, and organizing music becomes a task.  It took about 5 hours of creating all of the folders I needed, and the script did the rest.

There were a couple of steps I used to get everything in line.  First, I created the folder structure.  I used http://musicbrainz.org/ to find all of the albums that each mp3 belonged to, and created the folders as ‘music/artist/album/song.mp3‘.

While creating all of the album folders, I copied all of the songs into their respective folder, and then used Thunar’s “bulk renamer” to name all of the mp3′s ‘## – artist – song name.mp3‘.

After everything was organized, I emerged id3 and id3v2.  The first and seconds scripts that were wrote actually had to rename all of the files so that I could use deliminators to identify and extract the song name and the track number from the file name.  The second script actually clears and re-tags all of the mp3′s.

Script 1: changes all of ‘ – ‘ to ‘ _’

#!/bin/bash
find . −name "*.mp3" > /tmp/list
cat /tmp/list | while read filename;
do echo "old name was  " "${filename}";
newname=`echo "${filename}" | sed "s/\ \−\ /\ \_/g"`
echo "new name is " "${newname}"
mv "${filename}" "${newname}"
done
rm /tmp/list

Script 2: changes all of ‘.mp3′ to ‘ _.mp3′

#!/bin/bash
find /media/storage/media -name "*.mp3" > /tmp/list
cat /tmp/list > while read filename;
do echo "old name was  " "${filename}";
newname=`echo "${filename}" | sed "s/.mp3/\ \_.mp3/g"`
echo "new name is " "${newname}"
mv "${filename}" "${newname}"
done
rm /tmp/list

Script 3: tags all of the mp3′s with Artist, Album, Number, Song. Note: the directory in the first line for the find command is the main folder were all my music is stored, and under the “ARTIST= / ALBUM=” lines below, the -f # represents how many layers deep each respective folder is for the tag. For instance, /media/storage/media/Music/Artist/Album, the Artist folder is 6 levels deep and the Album folder is 7 layers deep (don’t forget to include the root directory for one level).

#!/bin/bash
find /media/storage/media/Music -name "*.mp3" > /tmp/list
cat /tmp/list | while read filename;
do
rm /tmp/num
PWD=`pwd`
ARTIST=`echo "${filename}" |cut -f 6 -d "/"`
ALBUM=`echo "${filename}" |cut -f 7 -d "/"`
`echo "${filename}" |cut -f 1 -d "_" > /tmp/NUM`
NUMBER=`cat /tmp/NUM | cut -f 8 -d /`
SONG=`echo "${filename}" |cut -f 3 -d "_"`
echo "setting title for id3 tags for " "${filename}";
echo "artist: $ARTIST"
echo "album: $ALBUM"
echo "track: $NUMBER"
echo "song: $SONG"
id3v2 -D "${filename}"
id3tag -a "${ARTIST}" -A "${ALBUM}" -s "${SONG}" -t "${NUMBER}" "${filename}"
done
rm /tmp/list

The third script took about 5 minutes to run, and all of the files were tagged properly. To et the file names back to normal, you simply have to reverse the ‘sed’ command in the first two scripts.

Redsn0w, Linux and Jailbreaking iPhones

redsn0w_iPod_d-tI finally got my iPhone jailbroken in linux using VirtualBox and Redsn0w.  I know this isn’t the primary method that people want to use, but it is a step in the right direction.

There is a lot of having to re-connect the device because it will disconnect itself from the virtual machine, but as long as you are paying attention, then you shouldn’t have a problem.

On another note, I haven’t given up on trying to sync the iPhone 3G running the 3.0 firmware with Amarok, but things have been slow.  I started up again, and ran right into the same problem I had last time, where does the FirewireGUID information get saved?  There also seems to be problems with the permissions once logged into the iPhone via ssh.  Hopefully soon I will figure this one out.