Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Maintaining my music collection (off topic)

1 view
Skip to first unread message

Fafa Hafiz Krantz

unread,
Oct 26, 2005, 5:10:53 AM10/26/05
to

Hello!

I have a rather large collection of CDs and vinyls which I have
digitized for preservation. For instance:

+----/usr/home/mp3
| +-----instrumentals/
| | +-----fat_jon_as_maurice_galactica-humanoid_erotica-cd-2001/
| | | +-----00-fat_jon_as_maurice_galactica-humanoid_erotica-2001-back.jpg
| | | +-----00-fat_jon_as_maurice_galactica-humanoid_erotica-2001-cd.jpg
| | | +-----00-fat_jon_as_maurice_galactica-humanoid_erotica-2001-front.jpg
| | | +-----00-fat_jon_as_maurice_galactica-humanoid_erotica-cd-2001.nfo
| | | +-----01-at_the_bar.mp3
| | | +-----02-14_years-nbd.mp3
| | | +-----03-triple_gold_daytons.mp3
| | | +-----04-no.mp3
| | | +-----05-tell_me.mp3
| | | +-----06-the_queen_and_i.mp3
| | | +-----07-backseat_anonymous-.mp3
| | | +-----08-change_your_mind.mp3
| | | +-----09-exact_space.mp3
| | | +-----10-i_dee.mp3
| | | +-----11-rain_dance_remix_instrumental.mp3
| | | +-----12-pretty_pussy_kitty_kat_ft_five_deez.mp3
| | | +-----13-unnamed_track.mp3

Inside mp3/ there are a lot of subfolders and subsubfolders
containing my albums. My problem is that they all lack a Simple File
Verification file as well as a M3U playlist. Generating those
manually for each album is way too much.

I was wondering if anybody could assist me in building this script
to perform these tasks:

1) Go to all directories containing an .nfo file
2) Generate an .sfv file based on the .mp3 files in each directory
3) Remove .sfv comments created by the cfv tool
4) Give the .sfv file the same name as the as the .nfo file (except extension)
5) Do an ls *.mp3 and output it to the same file name as the other two files (except extension)

So far a friend of mine has helped me make this:

fix() {
find ${1+:"$@"} -name '*.nfo' | while read file ; do
cd ${file%/*}

if [[ $(ls *.sfv) ]]; then
(( recreate )) && do=1 || do=0
else do=1
fi

(( do )) && cfv -C *.mp3 || { echo SFV creation failed. ; return 1 ; } ; ... filename code .. ;

cfv=$( ls *.cfv )
if [[ -n $cfv ]] ; then
echo SFV already exists.
else
Data=$( awk '! /^:/' $cfv ) && echo "$Data" >$cfv || echo Comment removal failed.
fi
}

But it doesn't really work.

# sh fix.sh
fix.sh: 9: Syntax error: "do" unexpected (expecting ")")

Maybe it also can be simplified?
I don't know much coding, but to me it looks kind of messy.

Well, that's it.
Thank you so much all!

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


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

_______________________________________________
freebsd-...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"

Parv

unread,
Oct 26, 2005, 6:39:48 AM10/26/05
to
in message <200510260910...@ws1-1.us4.outblaze.com>,
wrote Fafa Hafiz Krantz thusly...

>
> fix() {
> find ${1+:"$@"} -name '*.nfo' | while read file ; do
> cd ${file%/*}
^ ^
^ ^
Looks like this script is not going to work in FreeBSD /bin/sh.
Install one of shells/bash* (guessing) ports and run this script
under that shell (unless somebody does the conversion for you).


- Parv

--

Fafa Hafiz Krantz

unread,
Oct 26, 2005, 6:42:48 AM10/26/05
to

I don't know man,
the script is suppose to be valid sh.

# bash fix.sh
fix.sh: line 19: syntax error near unexpected token `}'
fix.sh: line 19: `}'

All the best,
Fafa

----- Original Message -----
From: Parv <pa...@pair.com>
To: "Fafa Hafiz Krantz" <ft...@london.com>
Subject: Re: Maintaining my music collection (off topic)
Date: Wed, 26 Oct 2005 06:39:48 -0400

>
> in message <200510260910...@ws1-1.us4.outblaze.com>,
> wrote Fafa Hafiz Krantz thusly...
> >
> > fix() {
> > find ${1+:"$@"} -name '*.nfo' | while read file ; do
> > cd ${file%/*}
> ^ ^
> ^ ^
> Looks like this script is not going to work in FreeBSD /bin/sh.
> Install one of shells/bash* (guessing) ports and run this script
> under that shell (unless somebody does the conversion for you).
>
>
> - Parv
>
> --

--


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


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

_______________________________________________

Will Maier

unread,
Oct 26, 2005, 3:47:39 PM10/26/05
to
On Wed, Oct 26, 2005 at 06:39:48AM -0400, Parv wrote:
> Looks like this script is not going to work in FreeBSD /bin/sh.
> Install one of shells/bash* (guessing) ports and run this script
> under that shell (unless somebody does the conversion for you).

FreeBSD sh (1) supports parameter expansion, including expansions used
in the referenced function.

--

o--------------------------{ Will Maier }--------------------------o
| jabber:..wcmaier@jabber.ccc.de | email:..........wcmaier@ml1.net |
| \.........wcm...@cae.wisc.edu | \..........wcm...@cae.wisc.edu |
*------------------[ BSD Unix: Live Free or Die ]------------------*

Parv

unread,
Oct 27, 2005, 5:15:59 AM10/27/05
to
in message <20051026194739.GL29508@localdomain>,
wrote Will Maier thusly...

>
> On Wed, Oct 26, 2005 at 06:39:48AM -0400, Parv wrote:
> > Looks like this script is not going to work in FreeBSD /bin/sh.
> > Install one of shells/bash* (guessing) ports and run this script
> > under that shell (unless somebody does the conversion for you).
>
> FreeBSD sh (1) supports parameter expansion, including expansions used
> in the referenced function.

(The deleted part Will M refereed above was similar to ${var%/*}.)

Yes, you are correct. I misremembered and did not paid much
attention to sh(1) man page before firing off my earlier post.


- Parv

--

Fafa Hafiz Krantz

unread,
Oct 28, 2005, 7:24:13 AM10/28/05
to

Here's what I ended up with:

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

for file in `find /home/mp3 -name \*.nfo`; 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}
cfv -C *.mp3
cat ${CURRENT}.sfv | awk '! /^;/' > ${SFV}
rm -f ${CURRENT}.sfv

for mp3 in `find * -name \*.mp3 -maxdepth 1`; do
echo "${mp3}" >> ${M3U}
done

done

:)

----- Original Message -----
From: "Will Maier" <will...@ml1.net>
To: freebsd-...@freebsd.org
Subject: Re: Maintaining my music collection (off topic)

Date: Wed, 26 Oct 2005 14:47:39 -0500

>
> On Wed, Oct 26, 2005 at 06:39:48AM -0400, Parv wrote:
> > Looks like this script is not going to work in FreeBSD /bin/sh.
> > Install one of shells/bash* (guessing) ports and run this script
> > under that shell (unless somebody does the conversion for you).
>
> FreeBSD sh (1) supports parameter expansion, including expansions used
> in the referenced function.
>

> --
>
> o--------------------------{ Will Maier }--------------------------o
> | jabber:..wcmaier@jabber.ccc.de | email:..........wcmaier@ml1.net |
> | \.........wcm...@cae.wisc.edu | \..........wcm...@cae.wisc.edu |
> *------------------[ BSD Unix: Live Free or Die ]------------------*

--


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


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

_______________________________________________

Nick Larsen

unread,
Oct 31, 2005, 5:01:00 AM10/31/05
to
Just for shell scripters' information:

the line in the script:


PREFIX="`basename ${file} | sed 's/.nfo//g'`"

could be replaced with the simpler:
PREFIX="`basename ${file} .nfo`"

basename can remove whatever you give as $2

> > | \.........wcm...@cae.wisc.edu <http://cae.wisc.edu> |
> \..........wcm...@cae.wisc.edu <http://cae.wisc.edu> |

0 new messages