📟 FFMPEG Script for Audio Conversion


Usage:

Prerequisite: FFmpeg. You should be able to download this via terminal or your distro's software repo.

  1. Read and understand the script logic. Don't download / run anything some random person posts on the internet!
  2. Save the following script into a .sh file (or simply paste it in terminal, in the your desired directory
  3. If saving this as a .sh file. In terminal, you may need to run $ chmod +x YOUR_FILE_NAME_HERE.sh in order to make it executable.
  4. Run it!

What Happens:

The script runs 2 for loops, looking for any file in the directory it's ran in that includes a .m4a or .opus file extension. When a file is found, it prints that filename to the terminal window (as a confirmation something was found). It then runs ffmpeg to stream that data into a new file named ORIGINAL_FILE_NAME.mp3 in .mp3 format. Note, if you already have a file named ORIGINAL_FILE_NAME.mp3, it will ask you if you want to overwrite it.

Code:

for i in *.m4a;
  do name=`echo "${i%.*}"`;
  echo "$name"
  ffmpeg -i "$i" "${name}.mp3"
done
for i in *.opus;
  do name=`echo "${i%.*}"`;
  echo "$name"
  ffmpeg -i "$i" "${name}.mp3"
done

    

zzz