Run this single-line Bash in the directory with * .wav files.
for wavfile in *.wav; do \ sox "${wavfile}" "preview-${wavfile}" trim 0 60 fade 3 57 3; \ lame --preset standard "preview-${wavfile}" \ "preview-`basename ${wavfile} .wav`".mp3; \ rm "preview-${wavfile}"; \ done
The first 60 seconds. 3 seconds of attenuation and 3 seconds of extinction. The wav source files remain untouched. Preview files come prefixed with "preview-". You can choose the location and length by changing the βtrim 0 60β to fit your needs. Requires: sox, lame
If you have a directory with mp3 files and you need to create a preview, run this:
for mp3file in *.mp3; do \ mpg123 -w "${mp3file}.wav" "${mp3file}"; \ sox "${mp3file}.wav" "preview-${mp3file}.wav" trim 0 60 fade 3 57 3; \ rm "${mp3file}.wav"; \ lame --preset standard "preview-${mp3file}.wav" "preview-${mp3file}"; \ rm -v "preview-${mp3file}.wav"; \ done
Requires: mpg123, sox, lame
source share