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:
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.$ ripcdaudio 1 song name 2 other song name 5 another song 8 lots of s +ongs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ripping CDs using cdparanoia
by Skeeve (Parson) on Oct 02, 2005 at 23:13 UTC |