Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an Ubuntu server installation set up as a media server with Subsonic in a medium sized office environment. I allow uploads from all employees to the media folder on the server.

As you can imagine, it's going to get a bit messy in there with multiple spellings of artist and album names for directory names, duplicate files, and incorrect filenames and tags.

I was hoping I could find a script that I could run daily as a cron job to clean up the media drive. Does anyone know of any that might work? I would like to maintain a path similar to: /mnt/music/Artist/Album/Song.file

share|improve this question

2 Answers 2

I found this script http://www.skryking.net/post/bash-sort-mp3-s-by-id3-tag:

#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

for i in `ls -1 *.mp3`
do
TITLE="`id3info "$i" | grep '^=== TIT2' | sed -e 's/.*: //g'`"
ARTIST="`id3info "$i" | grep '^=== TPE1' | sed -e 's/.*: //g'`"
ALBUM="`id3info "$i" | grep '^=== TALB' | sed -e 's/.*: //g'`"
YEAR="`id3info "$i" | grep '^=== TYER' | sed -e 's/.*: //g'`"
TRACKNUM="`id3info "$i" | grep '=== TRCK' | sed -e 's/.*: //g'`"

if [ -e "$TITLE" ]; then
  TITLE="Unknown"
fi

if [ -e "$ARTIST" ]; then
  ARTIST="Unknown"
fi

if [ -e $ALBUM ]; then
  ALBUM="Unknown"
fi

if [ -e $YEAR ]; then
  YEAR="Unknown"
fi

if [ -e $TRACKNUM ]; then
  TRACKNUM="Unknown"
fi

echo "$ARTIST $TITLE $ALBUM $YEAR $TRACKNUM"

install -D "$i" /storage/Multimedia/Music/"$ARTIST"/"$ALBUM"/"$i"
echo "/storage/Multimedia/Music/$ARTIST/$ALBUM/$i" >> filelist.txt

done

IFS=$SAVEIFS

Obviously you will need to modify this to use your specific folders. It requires all the unsorted music to be in one folder and doesn't go into sub folders but other than that it's great.

share|improve this answer

I used to have a similar arrangement. The method I settled for was not letting people write to the actual end directory and instead had an incoming directory that once a day processed all the files and in doing so, moved them to the music directory.

I found this a lot better as I could deal with metadata and get rid of junk files all in one swoop.

This isn't going to be the most useful post because I lost the script I wrote to do this. It was a Python script that grabbed album art from Amazon, checked CDDB if there wasn't metadata, etc. If you're looking for a quick Python project, I can heartily recommend it - It was fun.

Otherwise, you could use the incoming arrangement and run something like Banshee which has a great music-organising engine within it. The only problem is you'd have to do the imports manually as I don't think there's an auto-import function.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.