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.


In reply to Ripping CDs using cdparanoia by Tanktalus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.