I have a folder full of
.wav audio files.
Some are stereo, most are mono splits.
The mono split pairs are all named
foo bar track.L.wav and
foo bar track.R.wav
I can use the command line tool
sox to combine a mono pair into 1 stereo track like this:
sox -M track1.L.wav track1.R.wav track1.Stereo.wav
where the first 2 files are the mono pairs, and the third is the output stereo file.
This is great, but I'd like to have a script that will automatically find all the mono pairs and combine them into stereo files.
I.e., I need it to find all files which have the same name except for the
.R. before the extension, and run
sox on them, outputting to a new file with the same name without the
For example, if my folder contains these files:
track1.L.wav track2.L.wav track3.L.wav track4.L.wav track1.R.wav track2.R.wav track3.R.wav track4.R.wav track6.wav track7.wav
I need to run these commands:
sox -M track1.L.wav track1.R.wav track1.Stereo.wav sox -M track2.L.wav track2.R.wav track2.Stereo.wav sox -M track3.L.wav track3.R.wav track3.Stereo.wav sox -M track4.L.wav track4.R.wav track4.Stereo.wav
Here's where I am so far:
for file in ./*.L.wav; do file2=`echo $file | sed 's_\(.*\).L.wav_\1.R.wav_'`; out=`echo $file | sed 's_\(.*\).L.wav_\1.STEREO.wav_'`; echo $file - $file2 - $out; done
That works, but when I replace the
echo line with
sox -M $file $file2 $out;
it doesn't work; spaces in the filenames cause it to fail.