Skip to content

Instantly share code, notes, and snippets.

@hyjk2000
Last active March 25, 2021 11:09
Show Gist options
  • Save hyjk2000/9353962ce9bfd4b6d277c71688937d4e to your computer and use it in GitHub Desktop.
Save hyjk2000/9353962ce9bfd4b6d277c71688937d4e to your computer and use it in GitHub Desktop.
FFmpeg batch convert files in recursive directories
#!/usr/bin/env bash
# parallel runs in N-process batches
# https://unix.stackexchange.com/a/216475
N=4
# enable globstar, requires bash >=4.0
shopt -s globstar
for f in ../iTunes\ Media/**/*.m4a; do
((i=i%N)); ((i++==0)) && wait
fname="$(basename "$f")"
ffmpeg -i "$f" -c:a libmp3lame -q:a 0 -n "${fname%.*}.mp3" &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment