Skip to content

Instantly share code, notes, and snippets.

@pbojinov
Created October 20, 2017 18:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pbojinov/cf8ad1bcf72a96dc83080a06d3e4e902 to your computer and use it in GitHub Desktop.
Save pbojinov/cf8ad1bcf72a96dc83080a06d3e4e902 to your computer and use it in GitHub Desktop.
shell script to convert all wav files in the current working directory to mp3 files using ffmpeg
#!/bin/bash
FILES=*.wav
for f in $FILES
do
# echo "Processing ${f/.wav/.mp3} file..."
echo "Processing $f file..."
ffmpeg -i "$f" -codec:a libmp3lame -qscale:a 0 "${f/.wav/.mp3}"
# take action on each file. $f store current file name
# cat $f
done
# Source:
# file looping - https://www.cyberciti.biz/faq/bash-loop-over-file/
# string manipulation - http://www.tldp.org/LDP/abs/html/string-manipulation.html
# ffmpeg mp3 encoding guide - https://trac.ffmpeg.org/wiki/Encode/MP3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment