Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Ripping CDs using cdparanoia

by Tanktalus (Canon)
on Oct 02, 2005 at 03:01 UTC ( #496709=CUFP: print w/ replies, xml ) Need Help??

I've had need to rip many audio tracks on my Linux box. I never remember the command (cdparanoia) or its syntax. And running one command before typing in the next one seems silly - retyping "cdparanoia" each time is annoying, and allows the CD to spin down. Meanwhile, I don't really want the tracks to save as their track number, either, which would otherwise make shell scripting trivial: for x in 1 3 8 10; do cdparanoia $x $x.wav; done And, of course, tracks can have errors which could stream past the screen. So, perl to the rescue:

#!/usr/bin/perl use warnings; use strict; my @results; while (@ARGV) { my $track = shift; my $name; if ($track =~ /^(\d+)[=:](.*)$/) { $track = $1; $name = $2; } while (@ARGV and $ARGV[0] !~ /^\d/) { $name .= shift; } $name .= ".wav"; my @cmd = (qw(cdparanoia), $track, $name); print join(" ",@cmd),"\n"; system(@cmd); push @results, sprintf "%-30s - %s (%d)\n", $name, ($? == 0 ? 'SUC +CESS' : 'FAILURE'), $?; } print "\n\n"; print @results;

(Saved as "ripcdaudio") Usage:

$ ripcdaudio 1 song name 2 other song name 5 another song 8 lots of s +ongs
The code will remove those spaces, add the .wav extention, and rip one after another. Then it will print out the filenames and whether they were ripped ok or not at the end where you can see it without having to scroll back through dozens of lines of output.

Comment on Ripping CDs using cdparanoia
Select or Download Code
Re: Ripping CDs using cdparanoia
by Skeeve (Vicar) on Oct 02, 2005 at 23:13 UTC
    Cool... But it would be even cooler could you look up freedb for the CD's tracks and use that info for storing.

    But OTOH there is xmcd which can do this. But that's not perl...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://496709]
Approved by planetscape
Front-paged by planetscape
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-09-17 07:55 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (66 votes), past polls