Bash Script to Convert Multiple MP4 Files to MP3 Files



Apache/2.4.18 (Ubuntu) Server at Port 80
" data-via="andrewsirianni">Tweet

If you're using a Linux computer, Bash Scripts can be a powerful tool to help you complete useful tasks. A great script I have used is one that converts MP4 video files into MP3 audio files "on-the-fly". For me, this is a great way of converting online videos into audio files that I can listen to at any time.

The script below is a fairly simple script that finds all .mp4 files in a directory and creates a new .mp3 file - of the same name, in the same directory:

for f in *.mp4
name=`echo "$f" | sed -e "s/.mp4$//g"`
ffmpeg -i "$f" -f mp3 -ab 320000 -vn "$name.mp3"

Copy this script and save it as the following: in the directory with the MP4 files. Then you can run it from the terminal by navigating to that directory and typing ./

In order to run this script, you will need to install ffmpeg. To do so, open the terminal with Ctrl + Alt + T and type the following:

sudo apt-get install ffmpeg

I hope that this script comes in handy!

Share your comments or improvements to this script in the comment section below.

comments powered by Disqus

About Me

I design & develop software that runs on the Internet. As a qualified analyst, accountant and real estate agent, I can deploy systems that improve performance.


Warning: DOMDocument::load( failed to open stream: HTTP request failed! HTTP/1.0 410 Gone in /home/andrxvjf/public_etc/templates/rmargin/twitter.tpl.php on line 8

Warning: DOMDocument::load(): I/O warning : failed to load external entity "" in /home/andrxvjf/public_etc/templates/rmargin/twitter.tpl.php on line 8

Recent Tweets

Follow me: @andrewsirianni

Copyright ©2012 Andrew Sirianni, All Rights Reserved   LinkedIn Profile