Skip to content

Instantly share code, notes, and snippets.

@AmirAref
Created June 9, 2022 13:34
Show Gist options
  • Save AmirAref/74cce6822ca4178fff87b144326cbd71 to your computer and use it in GitHub Desktop.
Save AmirAref/74cce6822ca4178fff87b144326cbd71 to your computer and use it in GitHub Desktop.
a bash script to convert the all m4a files to the mp3 by ffmpeg
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
NC='\033[0m' # No Color]'
# Create the converted directory
DIR="Converted"
if ! test -d "$DIR"; then
echo "$DIR"
mkdir "$DIR"
fi
# convert the files
for f in *.m4a; do
new=$DIR/${f%.m4a}.mp3
# check the target file is exists
if test -f "$new"; then
echo -e "${Blue}$new${Green} File is exists !$NC"
continue
fi
# convert with ffmpeg
ffmpeg -i "$f" -codec:v copy -codec:a libmp3lame -q:a 0 "$new" ;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment