Saturday, April 14, 2012

Bash scripts

Forgive me for using this space to bookmark a few scripts I pick up all over the internet, this is for me personally, but anyone can copy and use as they please. This will be updated each time I find new and interesting scripts.

Batch convert .wav to .mp3:

Put this scripts in the same folder as all the .wav files and execute it.

Code:
#!/bin/sh
# wav to mp3

for i in *.wav; do
 if [ -e "$i" ]; then
   file=`basename "$i" .wav`
   lame -h -b 192 "$i" "$file.mp3"
 fi
done


You could also use ffmpeg if you get the following error:
Unsupported data format: 0x0011

Code:
#!/bin/sh
# wav to mp3

for i in *.wav; do
 if [ -e "$i" ]; then
   file=`basename "$i" .wav`
   ffmpeg -i "$i" "$file.mp3"
 fi
done

The reason for the error?
This indicates that the data was compressed using Microsoft's ADPCM
codec and LAME supports PCM only.

More to follow soon!

No comments: