bash script help

bash script help

Post by faeychil » Fri, 11 Apr 2003 18:23:05



I have no bash script skills at all

I want to convert collection of mp3 files
to wave or cdr
Using a script ripped off from the cdwrite howto ( below )
the result is a wave file with two extensions "file.mp3.wav".
Obviously I want only ".wav".

The "correct" script would be appreciated.

#!/bin/bash

for I in *.mp3

do

        mpg321 --w - "$I"  > "$I".wav

done

--
faeychild

 
 
 

bash script help

Post by Peter T. Breue » Fri, 11 Apr 2003 18:46:23



> I have no bash script skills at all
> I want to convert collection of mp3 files
> to wave or cdr
> Using a script ripped off from the cdwrite howto ( below )
> the result is a wave file with two extensions "file.mp3.wav".
> Obviously I want only ".wav".
> The "correct" script would be appreciated.

It is correct. Move them afterwards if you don't like the name. Anyway

  #!/bin/bash
  for i in *.mp3; do
    mpg321 --w - "$i"  > `basename $i .mp3`.wav
  done

Peter

 
 
 

bash script help

Post by Paul Colquhou » Fri, 11 Apr 2003 19:00:05


| I have no bash script skills at all
|
| I want to convert collection of mp3 files
| to wave or cdr
| Using a script ripped off from the cdwrite howto ( below )
| the result is a wave file with two extensions "file.mp3.wav".
| Obviously I want only ".wav".
|
| The "correct" script would be appreciated.
|
| #!/bin/bash
|
| for I in *.mp3
|
| do
|
|         mpg321 --w - "$I"  > "$I".wav
|
| done

#!/bin/bash

for I in *.mp3
do
        mpg321 --w - $I  > ${I%.mp3}.wav
done

Cryptic, isn't it? The '%.mp3' inside the curly braces returns the value
of the variable with the .mp3 extension removed. The actual value of the
variable is not changed.

This only works inside the braces. You can also use some wildcards, and
using '#' instead of '%' removes things from the beginning of the
variable instead of the end.

--
Reverend Paul Colquhoun, ULC.    http://andor.dropbear.id.au/~paulcol
     Asking for technical help in newsgroups?  Read this first:
        http://www.tuxedo.org/~esr/faqs/smart-questions.html

 
 
 

bash script help

Post by faeychil » Fri, 11 Apr 2003 19:56:22



> I have no bash script skills at all

> I want to convert collection of mp3 files
> to wave or cdr
> Using a script ripped off from the cdwrite howto ( below )
> the result is a wave file with two extensions "file.mp3.wav".
> Obviously I want only ".wav".

> The "correct" script would be appreciated.

> #!/bin/bash

> for I in *.mp3

> do

>         mpg321 --w - "$I"  > "$I".wav

> done

Thanks! I'll play around with both variations.
--
faeychild
 
 
 

bash script help

Post by William Par » Sat, 12 Apr 2003 01:48:34



> I have no bash script skills at all

> I want to convert collection of mp3 files
> to wave or cdr
> Using a script ripped off from the cdwrite howto ( below )
> the result is a wave file with two extensions "file.mp3.wav".
> Obviously I want only ".wav".

> The "correct" script would be appreciated.

> #!/bin/bash

> for I in *.mp3

> do

>        mpg321 --w - "$I"  > "$I".wav

> done

For files already converted,
    rename '.mp3' '' *.wav
For new files,
    mpg321 ... > `basename $I .mp3`.wav
    mpg321 ... > ${I%.mp3}.wav

--

Linux solution for data management and processing.