Linux.com

Re: CLI Magic: For geek cred, try these one-liners

Posted by: Anonymous [ip: 67.152.57.254] on July 24, 2008 03:08 PM
Well, this doesn't work if the top level dir has regular files in it :-/

I'd propose using find(1)

find . -name '*.wav' -maxdepth 2 | while read FILE; do lame -b 32 "${FILE}" "${FILE%.wav}.mp3"; done

The use of -maxdepth constrains the find(1) to the current dir and 1 level down.

Using $(ls -1) as an element list to a for loop runs the risk of overflow should there be a large number of files in a given directory.

Use of {xxx%yyy} is a nice construct.

I didn't know lame can convert from wav to mp3 (I've be using audacity for this) thanks for the hint.


#

Return to CLI Magic: For geek cred, try these one-liners