public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
* My first bash script.
@ 2005-01-01 22:55 Jeremy Abbott
  2005-01-01 22:58 ` Jeremy Abbott
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Abbott @ 2005-01-01 22:55 UTC (permalink / raw)
  To: linux-newbie

I wrote my first bash script the other day to automatically rip my CDs 
to 128k mp3s.  I was wondering if anyone had any idea or suggestions for 
the script to improve or streamline it.  Thanks in advance. Here it is:

#!/bin/bash
#
# The purpose of this script is to automatically rip CD's to wav format,
# ask for artist name, and track titles and then encoding them into mp3's
# with the following naming conventions:
#
# Track# - Artist - Track title.mp3
# eg. 01 - Metallica - Blackened.mp3 or 02 - Metallica - ...And Justice 
For All.mp3


# make a temp directory, and copy tracks off of /dev/cdrom into temp 
folder using
# cdparanoia

STARTING_DIR=`pwd`

if [ -d $HOME/TEMPRIPPER ]; then
    cd $HOME/TEMPRIPPER
else
    mkdir $HOME/TEMPRIPPER &
    cd $HOME/TEMPRIPPER
fi

cdparanoia -B

# Ask user for artist name, then titles for provided track number, then 
encodes
# the correct track number into an mp3 using the naming conventions 
found in
# the header.

TRACKNUM=01
clear

echo -n "Who is the artist? "
read ARTIST

while [ -a track${TRACKNUM}.cdda.wav ]
do
    if [ -a $HOME/TEMPRIPPER/track${TRACKNUM}.cdda.wav ]; then
        echo -n "What is the title of track $TRACKNUM? "
        read TITLE       
        lame -h $HOME/TEMPRIPPER/track${TRACKNUM}.cdda.wav 
$STARTING_DIR/"$TRACKNUM - $ARTIST - $TITLE.mp3"
        TRACKNUM=`expr $TRACKNUM + 1`
        if test $TRACKNUM -lt "10"; then
            case $TRACKNUM in
                2) TRACKNUM=02;;
                3) TRACKNUM=03;;
                4) TRACKNUM=04;;
                5) TRACKNUM=05;;
                6) TRACKNUM=06;;
                7) TRACKNUM=07;;
                8) TRACKNUM=08;;
                9) TRACKNUM=09;;
            esac
        fi
    fi
done

cd $STARTING_DIR
rm -rf $HOME/TEMPRIPPER

exit 0

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: My first bash script.
  2005-01-01 22:55 My first bash script Jeremy Abbott
@ 2005-01-01 22:58 ` Jeremy Abbott
  0 siblings, 0 replies; 2+ messages in thread
From: Jeremy Abbott @ 2005-01-01 22:58 UTC (permalink / raw)
  To: linux-newbie

Jeremy Abbott wrote:

> I wrote my first bash script the other day to automatically rip my CDs 
> to 128k mp3s.  I was wondering if anyone had any idea or suggestions 
> for the script to improve or streamline it.  Thanks in advance. Here 
> it is:
>
> #!/bin/bash
> #
> # The purpose of this script is to automatically rip CD's to wav format,
> # ask for artist name, and track titles and then encoding them into mp3's
> # with the following naming conventions:
> #
> # Track# - Artist - Track title.mp3
> # eg. 01 - Metallica - Blackened.mp3 or 02 - Metallica - ...And 
> Justice For All.mp3
>
>
> # make a temp directory, and copy tracks off of /dev/cdrom into temp 
> folder using
> # cdparanoia
>
> STARTING_DIR=`pwd`
>
> if [ -d $HOME/TEMPRIPPER ]; then
>    cd $HOME/TEMPRIPPER
> else
>    mkdir $HOME/TEMPRIPPER &
>    cd $HOME/TEMPRIPPER
> fi
>
> cdparanoia -B
>
> # Ask user for artist name, then titles for provided track number, 
> then encodes
> # the correct track number into an mp3 using the naming conventions 
> found in
> # the header.
>
> TRACKNUM=01
> clear
>
> echo -n "Who is the artist? "
> read ARTIST
>
> while [ -a track${TRACKNUM}.cdda.wav ]
> do
>    if [ -a $HOME/TEMPRIPPER/track${TRACKNUM}.cdda.wav ]; then
>        echo -n "What is the title of track $TRACKNUM? "
>        read TITLE              lame -h 
> $HOME/TEMPRIPPER/track${TRACKNUM}.cdda.wav $STARTING_DIR/"$TRACKNUM - 
> $ARTIST - $TITLE.mp3"
>        TRACKNUM=`expr $TRACKNUM + 1`
>        if test $TRACKNUM -lt "10"; then
>            case $TRACKNUM in
>                2) TRACKNUM=02;;
>                3) TRACKNUM=03;;
>                4) TRACKNUM=04;;
>                5) TRACKNUM=05;;
>                6) TRACKNUM=06;;
>                7) TRACKNUM=07;;
>                8) TRACKNUM=08;;
>                9) TRACKNUM=09;;
>            esac
>        fi
>    fi
> done
>
> cd $STARTING_DIR
> rm -rf $HOME/TEMPRIPPER
>
> exit 0
>
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>
One line was altered when I pasted it into Thunderbird. 

lame -h $HOME/TEMPRIPPER/track${TRACKNUM}.cdda.wav 
$STARTING_DIR/"$TRACKNUM - $ARTIST - $TITLE.mp3"

^ should have been on it own line.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-01 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-01 22:55 My first bash script Jeremy Abbott
2005-01-01 22:58 ` Jeremy Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox