I´m trying to batch process a great number of files using bash shell in Mac Terminal. The script is going to mix together 2 versions of the same audio file, that have been processed differently, using SoX Sound Exchange library and the -m
(for mix) command. I have been able to combine one simple mix of 2 separate files, like this:
sox −m file1.wav file2.wav mixed.wav
The above works like a charm and just outputs the correct result.
However, while writing the batch processing script, to get all files in the folder to be combined, I run into trouble. First off, my files are named as follows:
af01-sweep1.wav
af01-sweep2.wav
af02-sweep1.wav
af02-sweep2.wav
af03-sweep1.wav
af03-sweep2.wav
… and so forth…
Here is the script:
for file in ./*sweep1*
do
for file2 in ./*sweep2*
do
out=COMBINED
sox -V4 -m -v 1 $file -v 1 $file2 $file-$out.wav
done
done
What happens as a result of this script is that it combines every file with the token “sweep1” with every file containing “sweep2”. I need to just combine for ex af01-sweep1.wav with af01-sweep2.wav and so forth. I do not know what command or sign to put here to tell bash to look for the same name but with the difference of “sweep1” and “sweep2”. I have thousands of files, so making a script that handles couples is vital.
I´ve read around on bash solutions and found something called -NAME
and believe this to be able to be used together with commands like MATCH
or FIND
. Unsure, as I do not do programming normally.