LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-20-2004, 11:16 AM   #1
Aioth
LQ Newbie
 
Registered: Jun 2004
Location: Brisbane, Australia
Distribution: Slackware 9.1
Posts: 11

Rep: Reputation: 0
Bash Scripting Help


Gday everyone,

I'm trying to write a script which finds how many tracks are on a CD and then asks for that many Track Titles.

After that, it goes and ripps/encodes, but I've got that worked out already.

I'm kind of lost here, I know that I'll need to loop to ask for tracks, but I'm not sure how to go about it, or to work out the number of tracks (cdparanoia?)

Thanks in advance, be gentle

- Aioth
 
Old 09-20-2004, 12:04 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

Code:
TRACKS=`cdrecord -toc dev=????? 2> /dev/null | grep track | wc | awk '{print $1}'`
((TRACKS--))
Should give you the number of tracks on the CD (assuming it's BASH you're using).

Dave
 
Old 09-21-2004, 02:16 AM   #3
Aioth
LQ Newbie
 
Registered: Jun 2004
Location: Brisbane, Australia
Distribution: Slackware 9.1
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks!

I think I've got everything sorted now, I'm testing it as I type.
 
Old 09-21-2004, 02:51 AM   #4
Aioth
LQ Newbie
 
Registered: Jun 2004
Location: Brisbane, Australia
Distribution: Slackware 9.1
Posts: 11

Original Poster
Rep: Reputation: 0
Hmm, I've got just one more issue.

I was encoding to ogg a bit messily and just accepted the error messages.

Like this:

oggenc -q 8 -m 192 -a "$Art" -l "$Alb" -G "$Gen" -d "$Dat" -t "$T1" -N 1 track01.cdda.wav -t "$T2" -N 2 track02.cdda.wav -t "$T3" -N 3 track03.cdda.wav -t "$T4" .... -N 28 track28.cdda.wav -t "$T29" -N 29 track29.cdda.wav -t "$T30" -N 30 track30.cdda.wav -n "%a - %t.ogg"

Now, I'm wondering how to modify this to get it to work. I'm not sure how to work it with the 01 in the wav instead of a 1.
 
Old 09-21-2004, 08:51 AM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
What exactly is the problem?
 
Old 09-21-2004, 09:34 AM   #6
Aioth
LQ Newbie
 
Registered: Jun 2004
Location: Brisbane, Australia
Distribution: Slackware 9.1
Posts: 11

Original Poster
Rep: Reputation: 0
Well, what I have now spluts out a lot of "Cannot Find track##.cdda.wav" when I rip a CD with less than 30 songs. Now, how do I just go up to the number of tracks on the CD?

I was thinking of looping like

while [ "$var" -le "$TRACKS" ]

do

oggenc -q 8 -m 192 -a "$Art" -l "$Alb" -G "$Gen" -d "$Dat" -t "$T${var}" -N $var track${var}.cdda.wav -n "%a - %t.ogg

let "var += 1"

done

But I'm not sure how to make sure track${var}.cdda.wav ends up as a 2 digit number.
 
Old 09-21-2004, 09:38 AM   #7
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

Rep: Reputation: 30
Do you need to do this from a command line? Grip will rip and encode your CDs for you, and I believe it can also look them up on freedb to get track titles.
 
Old 09-21-2004, 09:49 AM   #8
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Here's what I'd do:

while [ "$var" -le "$TRACKS" ]

do

if [ $var -lt 10 ]
then
tempvar=0$var
else
tempvar=$var
fi

oggenc -q 8 -m 192 -a "$Art" -l "$Alb" -G "$Gen" -d "$Dat" -t "$T${tempvar}" -N $var track${tempvar}.cdda.wav -n "%a - %t.ogg

let "var += 1"

done

Or words to that effect.

Dave
 
Old 09-21-2004, 11:21 AM   #9
Aioth
LQ Newbie
 
Registered: Jun 2004
Location: Brisbane, Australia
Distribution: Slackware 9.1
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks ilikejam!

I think I've got it all fixxed up now.


dsegel, I tried using Grip, but it wasn't really what I wanted. And hey, I'm teaching myself a little bash while I'm at it (I'm only 15).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash scripting help (su ...) shwong Linux - General 1 11-02-2005 12:26 PM
Bash scripting pete1234 Programming 1 09-27-2005 01:48 AM
bash scripting vadon Linux - Newbie 6 05-10-2005 04:07 AM
need help with bash scripting rich2oo1 Programming 2 12-17-2003 12:50 PM
HELP with BASH scripting atwah Linux - Newbie 6 09-09-2003 01:10 AM


All times are GMT -5. The time now is 04:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration