I have many music files in flac format and I wanted to convert them to a more compressed mp3 format with ffmpeg on Ubuntu so I can upload them to a storage limited portable music player. To ease the conversion task, I decided to write this simple shell script to do the job. In brief, the script will do the following:
- find all the files with the extension .flac in the current directory
- replace the file name extension .flac with the .mp3 extension
- create a temporary script that calls the ffmpeg command to convert
- run the temporary script
The listing of the shell script is shown below.
To use this shell script, you can do the following:
- Save the code listing above to a file e.g. run.sh in a directory, e.g. /path/to
- Open up a Linux Terminal.
- In the Terminal, type in the command to change directory to the location of the flac files, e.g. /path/to/music/
$ cd /path/to/music
- At the prompt, type in the command to run the shell script.
$ bash /path/to/run.sh
The flac files are converted to mp3 files.