FFMPEG: Convert multiple files using xargs

I came across a large amount of files which I wanted to convert from webm to m4a (aac) for a project.

Once can go through and do it all manually, or write a bash script. for this, xargs is a very good solution.

Simply cd into the folder containing files and run the following command.

ls *.webm | xargs -I % ffmpeg -i % %.m4a

The key part of this one-liner is xargs -i %. This means that each line of STDIN passed to xargs is put into a variable and can be referenced as %. Hence, the following text which specifies ffmpeg -i x.webm x.m4a to make it convert.

Published 2016-12-22