Search code examples
linuxaudiomergebatch-processingsox

How to use sox with an audio file list


I'd like to merge several audio files. (I'm familiar with using command line tools, but have only rudimentary shell skills.)

Unlike other batch processing command line tools, sox doesn't seem to have a parameter that allows to specify a input file list.

According to the sox documentation, files can be merged using the following command:

sox -m input1 input2 ... inputN output

They also mention that file names can be piped from other apps but don't give any specific examples.

So how do I specify a text file that contains a list of the files to be merged as the input?

BTW, the format of the text file is:

fileRandomID1.wav
fileRandomID2.wav
fileRandomID3.wav

and all files need to be merged in the order in which they're listed in the text file.


Solution

  • If you have a list of the files that you want merged in MergeList.txt and it looks like this:

    fileRandomID1.wav
    fileRandomID2.wav
    fileRandomID3.wav
    

    You can do:

    sox -m $(cat MergeList.txt) output.wav