Convert m4a to ogg

How to convert multiple m4a audio files in one directory to ogg format in UbuntuLinux? That’s the question that got me started down this road.

I was hoping for an easy way to do multiple files using FFMPEG but I don’t understand the command line structure well enough. In the meantime, I ran across this script that does the job.

  1. Install faad and lame with the command – sudo apt-get install faad lame
  2. Copy-n-paste the script and save it as m4a2mp3.sh in your /home/usrdirectory
    (e.g. /home/mg)
  3. Make the script executable with this command – sudo chmod 777 m4a2mp3.sh
  4. Switch to the directory and call the script with /home/m4a2mp3.sh

(Note: If you find an error in these instructions, please let me know! Thx in advance!)

#!/bin/bash
#for i in *.wma ; do

current_directory=$( pwd )

#remove spaces
for i in *.[Mm]4[Aa]; do mv "$i" `echo $i | tr ' ' '_'`; done

#remove uppercase
for i in *.[Mm]4[Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done

#ripping with mplayer
echo Processing file: $i
#for i in *.mp3 ; do mplayer -vo null -vc dummy -ao pcm:file=$i.wav $i; done
for i in *.m4a ; do faad $i; done

#Convert to OGG
oggenc *.wav;

#removing old file
rm *.wav;
#rm *.m4a

How would one do this for multiple files with FFMPEG?


var addthis_pub=”mguhlin”;


Subscribe to Around the Corner-MGuhlin.org


Be sure to visit the ShareMore! Wiki.


Discover more from Another Think Coming

Subscribe to get the latest posts sent to your email.

10 comments

  1. You do not need sudo to 'chmod' a file that you created in your home dir. And, you SHOULD NOT 'chmod 777' because that will give WRITE permission to ALL users. This is absolutely terrible suggestion 'chmod 777'. You could have just done:##chmod +x script.sh

  2. You do not need sudo to 'chmod' a file that you created in your home dir. And, you SHOULD NOT 'chmod 777' because that will give WRITE permission to ALL users. This is absolutely terrible suggestion 'chmod 777'. You could have just done:##chmod +x script.sh

  3. Hi. The problem I find, is that this post will teach people to ignore or downplay the importance of computer security. As a blogger trying to help other readers out, you ought to post code that is acceptably security, at least moderately secure. This way, the hundreds of thousands of people that followed this advice, won't have 777 scripts strewn about their home-dirs (or worse) root-dirs.Thanks,Felipe

  4. Hi. The problem I find, is that this post will teach people to ignore or downplay the importance of computer security. As a blogger trying to help other readers out, you ought to post code that is acceptably security, at least moderately secure. This way, the hundreds of thousands of people that followed this advice, won't have 777 scripts strewn about their home-dirs (or worse) root-dirs.Thanks,Felipe

Leave a reply to Anonymous Cancel reply