Created
September 7, 2015 13:23
-
-
Save probil/314e56739d83aab0a63f to your computer and use it in GitHub Desktop.
Normalize audio files in dir and subdir
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
#!/usr/bin/env bash | |
cd $1 | |
find . type f | grep mp3$ > mp3-files.txt | |
readarray -t files < mp3-files.txt | |
INDEX=0 | |
LENGTH=${#files[@]} | |
for file in "${files[@]}"; do | |
INDEX=$((INDEX+1)) | |
percent=$(printf '%i %i' $INDEX $LENGTH | awk '{ pc=100*$1/$2; i=int(pc); print (pc-i<0.5)?i:i+1 }') | |
echo "Converting... [$percent%] $file" | |
ffmpeg -loglevel panic -i "$file" -vn -ar 44100 -ac 2 -q:a 5 temp.mp3; | |
rm "$file"; | |
mv temp.mp3 "$file"; | |
done | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment