Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Ripping CDs using cdparanoia

by Tanktalus (Canon)
on Oct 02, 2005 at 03:01 UTC ( [id://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.

Replies are listed 'Best First'.
Re: Ripping CDs using cdparanoia
by Skeeve (Parson) 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...

    $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-19 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found