Created
January 7, 2018 19:10
-
-
Save alecjacobson/a5e02d076b3396c624d611538b6f7c0f to your computer and use it in GitHub Desktop.
Concatenate all mp3s in a directory and subdirectories into a single mp3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/alecjacobson/b4e8f59bbd251ed81df4c5fe8441f630 | |
# | |
# brew install ffmpeg --with-fdk-aac | |
OLDPWD=$( pwd ) | |
cd "$1" | |
# Sort files so that ./Disc 10/1.mp3 is after ./Disc 9/1.mp3 | |
paths=$( find . -name "*.mp3" | sed 's/\([0-9]\)/;\1/' | sort -n -t\; -k2,2 | tr -d ';') | |
echo "$paths" | |
concat_paths=$( echo "$paths" | tr '\n' '|' ) | |
ffmpeg -i "concat:$concat_paths" -c:a copy -f mp3 "$2" | |
cd "$OLDPWD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment