mp3.sh: Asking for advice

Fafa Hafiz Krantz fteg at london.com
Mon Oct 31 05:02:36 PST 2005


Hello!

I got this script here:

#!/bin/sh
#
#   Generate SFV and M3U for MP3 releases.
#   $URBAN: mp3.sh,v 1.0 2005/10/24 15:05:09 fafa Exp $
#

for file in `find . -name \*.nfo | sed 's,^\./,,'`; do

	directory="`dirname ${file}`"
	prefix="`basename ${file} | sed 's/.nfo//g'`"
	current="`basename ${directory}`"
	sfv="${directory}/${prefix}.sfv"
	m3u="${directory}/${prefix}.m3u"

		cd ${directory}
		
		rm -f *.sfv
		rm -f *.m3u
		
		touch ${sfv}
		if [ test `cfv -C *.mp3 > &>/dev/null` -nq 0 ]
			echo "CFV returned non-zero result."
			break
		fi
		
		cat ${current}.sfv | awk '! /^;/' > ${sfv}
		rm -f ${current}.sfv
		
		for mp3 in *.mp3;
		do echo "${mp3}" >> ${m3u};
		done

	echo "$directory: Done"

done

In some cases though, an album contains two or more CDs -- making the files start
with 3 digits, and not 2 like normal -- such as cd/track: 101, 102 etc. for CD1 and
201, 202 etc. for CD2. If this is the case, then one .m3u (playlist) should be
generated for each CD, like ${prefix}-cd1.m3u, ${prefix}-cd2.m3u etc.

Now, I'm a super newbie when it comes to scripting. I have no idea what to do. I've
been told I can use sed, or maybe echo $filename | egrep '^[[:digit:]]{2}[^[:digit:]]'
but I am clueless as to how I could make that all work with my script.

If anybody has a clue, please do share it :)

Thanks you all ...

--
Fafa Hafiz Krantz
  Research Designer @ http://www.bleed.com


-- 
___________________________________________________
Play 100s of games for FREE! http://games.mail.com/



More information about the freebsd-questions mailing list