Convert a bunch of wav files into mp3 format

Use the following statement to convert a bunch of waveform audio format (wav) files within a folder into mp3 format. The script is based on the well known lame mp3 encoder.

bash# for line in $(ls  .wav | perl -pe 's/(.).wav/$1/'); \
do lame -b 192 -h $line.wav $line.mp3 ; done;

Advertisement

Resize multiple images using Imagemagick

Ever tried to resize a whole folder of images in a single line? Make sure you have  the imagemagick convert utility installed. Paste to following line into your bash

bash# ls -1 *.jpg > images; while read line; do SRC=$line; cp $line temp.jpg; convert -resize 400x400 temp.jpg $SRC; done < images; rm images temp.jpg

The command will resize alle images to 400 pixels height or width depending on the orientation of the image. Thus, the propotions of the image will not change.