The Forums > Linux Tips & Tricks

Batch converting .ogg to .mp3 keeping the ID tag metadata

(1/2) > >>

Mark Greaves (PCNetSpec):
CLI method  .. For command line junkies.

"cd" to the directory containing your .ogg files:

--- Code: ---
cd /path/to/directory/containing/ogg/files
--- End code ---

Run this command to have ffmpeg batch convert all the .ogg files to mp3:

--- Code: ---
for name in *.ogg; do ffmpeg -i "$name" -ab 128k -map_meta_data 0:0,s0 "${name/.ogg/.mp3}"; done;
--- End code ---

That will convert ALL the .ogg files to (128k bitrate) .mp3 .. it will automatically change the file extension .. and it will keep all the ID tag metadata.

If you want to use a different bitrate .. just change the 128k to your chosen bitrate.

GUI method .. for everyone else :)

Simple, install the soundconverter package .. or if you're using KDE, soundkonverter

Now use it to convert your files.

The command you have provided has some errors

The proper command would be:

for name in *.ogg; do ffmpeg -i "$name" -ab 128k -map_metadata 0:s:0 "${name/.ogg/.mp3}"; done;

Mark Greaves (PCNetSpec):
Yup, -map_meta_data now appears to be depreciated.

Thanks for the update :)

I have a response on this old post, first to thank the original poster for this nice command. There was however a problem I encountered on Windows: the tags were not visible in Explorer and WMP (although correctly copied). A solution to this was found here and here and I wanted to share that solution.

So if Windows users have problems with the tags not showing up, one could try this:

--- Code: ---
for name in *.ogg; do ffmpeg -i "$name" -ab 128k -map_metadata 0:s:0 -id3v2_version 3 -write_id3v1 1 "${name/.ogg/.mp3}"; done;
--- End code ---

Mark Greaves (PCNetSpec):
Nice, thanks for that.

and welcome to the forum mhvis :)


[0] Message Index

[#] Next page

Go to full version