-
-
Save zrahman001/69e33bcd9c42532b40e9 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Converts audio formats in bulk | |
# requires avconv | |
fformat=m4a | |
tformat=mp3 | |
c=0 | |
t=0 | |
files=*.$fformat | |
echo Scanning directory . . . | |
for file in $files; do | |
t=$[t+1] | |
echo "#$t: $file" | |
done | |
echo "Found $t file(s):" | |
read -p "Do you want to see avconv's output? (y/n) (default: n)" avcout | |
for file in $files; do | |
fname="${file%.*}" | |
c=$[c+1] | |
echo "Converting ($c/$t)" | |
echo "From: $fname.$fformat" | |
echo "To: $fname.$tformat" | |
if [ "$avcout" == "y" ]; then | |
avconv -i "$fname.$fformat" "$fname.$tformat" | |
else | |
avconv -i "$fname.$fformat" "$fname.$tformat" 2> /dev/null | |
fi | |
done | |
read -p "Do you want to keep all .$fformat files (0), remove them (1), or something else (2)? (default: 0)" choice | |
if [ "$choice" == "1" ]; then | |
rm *.$fformat | |
elif [ "$choice" == "2" ]; then | |
rm -i *.$fformat | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment