Ubuntu – How to convert multiple files to mp3 in Thunar custom actions

convertmp3thunarthunar-custom-actions

I have added a simple command avconv -i %f %f.mp3 to Thunar's custom actions to convert a selected media file to mp3 (in the same folder and with the same name).

enter image description here

What would be the command that can be added in the same way that would allow selecting multiple files or an entire folder to convert them to mp3 (with the source's folder and name)?

I expect them to be converted one by one (not in parallel, that is, not all at the same time) – but I was wandering if that could be done with one context menu command after selecting multiple files.


It looks like avconv does not support multiple files per input (see comment under here), I am not asking necessarily for a command that includes avconv, but for any other solution.

Best Answer

It depends a little, on how Thunar handles multiple files. Basically, you can use parallel (website) to handle a lot of files.

sudo apt-get install parallel

So I would start with the following:

parallel avconv -i '{}' '{}.mp3' ::: %F

By default, it only does one job at a time. If you want to use multiple CPU cores in parallel, try parallel -j 4 ... for 4 jobs in parallel. Also check out man parallel.


In order to run it in Thunar's custom actions, this should be embedded like so:

xfce4-terminal -e "parallel avconv -i '{}' '{}.mp3' ::: %F"


To convert to other audio formats supported by avconv, just replace mp3 with that - but: take into consideration other issues like:

  • flv and mp4 files contain aac audio and converting that to other audio formats may entail unwanted results - more here. If the aac file has about 95 kbps bitrate converting directly to mp3 would work, because the default bitrate for the mp3 would be 192kbps, which is a good option (according to here). If the aac file has a different bitrate, the mp3 should be modified accordingly.

  • aac is a lossy format, and converting it to other formats should be considered in the context of the larger issue that converting between lossy formats is not recommendable. Even more, converting from a lossy format to a lossles one is pointless.

  • a better option than converting aac to mp3 would be to just extract the aac audio into a m4a container, as described here.