| Art Alexion on 19 Jan 2006 16:32:37 -0000 |
|
My scripting ability is limited to looking at existing scripts, trying
to figure out how and why they work, and using those guesses to modify them.
I have a number of flac files I have burned as audio-cd, and want to now
convert the flac files to a compressed format. I have a simple script
that does flac2ogg, but ogg doesn't play well with my cd player, so I
want to convert to mp3, that does. I found the following script that
accomplishes this with flac and lame (for audio conversion) and metaflac
and id3ed (for tag conversion).
===== start =====
#!/bin/bash
PRESET=$1
DESTDIR=$2
if test "x$PRESET" = "x"; then
PRESET=extreme
fi
if test "x$DESTDIR" = "x"; then
DESTDIR=.
else
mkdir -p "$DESTDIR"
fi
echo
echo "Preset=$PRESET Destination=$DESTDIR Source=`pwd`"
echo
for a in *.flac
do
OUTF=`echo "$a" | sed s/\.flac/.mp3/g`
echo
echo "Source=`pwd`/$a Destination=$DESTDIR/$OUTF"
echo
ARTIST=`metaflac "$a" --show-tag=ARTIST | sed s/.*=//g`
TITLE=`metaflac "$a" --show-tag=TITLE | sed s/.*=//g`
ALBUM=`metaflac "$a" --show-tag=ALBUM | sed s/.*=//g`
YEAR=`metaflac "$a" --show-tag=DATE | sed s/.*=//g`
GENRE=`metaflac "$a" --show-tag=GENRE | sed s/.*=//g`
TRACKNUMBER=`metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g`
COMMENT=`metaflac "$a" --show-tag=DESCRIPTION | sed s/.*=//g`
echo
echo "Launching: flac -c -d $a | lame --preset $PRESET -
$DESTDIR/$OUTF"
echo
flac -c -d "$a" | lame --preset $PRESET - "$DESTDIR/$OUTF"
echo
echo "Setting id3 ($TITLE, $TRACKNUMBER, $ARTIST, $ALBUM, $GENRE)"
echo
if test "x$TITLE" != "x"; then
id3ed -sq "$TITLE" "$DESTDIR/$OUTF" > /dev/null
fi
if test "x$TRACKNUMBER" != "x"; then
id3ed -kq "$TRACKNUMBER" "$DESTDIR/$OUTF" > /dev/null
fi
if test "x$ARTIST" != "x"; then
id3ed -nq "$ARTIST" "$DESTDIR/$OUTF" > /dev/null
fi
if test "x$ALBUM" != "x"; then
id3ed -aq "$ALBUM" "$DESTDIR/$OUTF" > /dev/null
fi
if test "x$YEAR" != "x"; then
id3ed -yq "$YEAR" "$DESTDIR/$OUTF" > /dev/null
fi
if test "x$COMMENT" != "x"; then
id3ed -cq "$COMMENT" "$DESTDIR/$OUTF" > /dev/null
fi
if test "x$GENRE" != "x"; then
id3 -gq "$GENRE" "$DESTDIR/$OUTF"
fi
done
======= end =======
The script originally used id3 instead of id3ed, and lacked conversion
for the year and comment fields. id3 supports the writing of the year
field, but not the comment field, so first I modified it to support the
year field. That worked.
So then I noticed that I also had id3ed which supports the comment
field, so, after reading the id3ed man page, I reworked the script to
above. Now it chokes and stalls.
Any ideas what I did wrong and suggestions?
Switching
--
_______________________________________
Art Alexion
Arthur S. Alexion LLC
PGP fingerprint: 52A4 B10C AA73 096F A661 92D2 3B65 8EAC ACC5 BA7A
The attachment -- signature.asc -- is my electronic signature; no need
for alarm.
Info @
http://mysite.verizon.net/art.alexion/encryption/signature.asc.what.html
Key for signed PDFs available at
http://mysite.verizon.net/art.alexion/encryption/ArthurSAlexion.p7c
The validation string is TTJY-ZILJ-BJJG.
________________________________________
Attachment:
signature.asc Attachment:
signature.asc ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|