i would like to be able to batch mix a bunch of wav files i have in a folder using a bat file with sox..
basically in that folder i have 2 versions of every file, let's say a file named "Brother.wav" and a file named "Brother (2).wav". I would like them both mixed and creating a new "Brother (3).wav" file, and i would need this to happen to every file in the folder, so if i also have a file named "Sister.wav" and a file named "Sister (2).wav" in that folder, it would also work on it to create a "Sister (3).wav" mixed wav file, and so on. The thing is i have no idea what i should write in the bat file for this to work, or even if that is a possibility
What i have so far in my bat file is this:
"C:\Program Files (x86)\sox-14-4-2\sox.exe" -m *.wav *(2).wav input3.wav
which doesn't do what i want, because it takes ALL the .wav in the folder and mix them together to create a single wav file named input3...
I'm sorry as this is probably a very noob issue, and i'm probably not explaining it properly, but i'm not used to using sox and bat files at all and i really need a way to automate that mixing process since i have a ton of files to go through :/
Thanks in advance for any answers!
One-liner:
Note that the
soxline will simply beECHOed for testing purposes. After you've verified that the commands are correct, changeECHO "C:\Prog…to"C:\Prog…to actually process the files.It's a matter of approach.
*.wavmeansALL .wav files, hence the results you report.This solution uses the characteristics of
forin two ways. Documentation aboutforcan be obtained by executingfor /?from the prompt - or thousands of examples on SO.First,
FOR %%e IN ("* (2).wav") DOassigns the name of each file matching* (2).wavto%%ein turn. The mask is quoted as it contains Space. (I was impressed that this actually worked! Normally, I'd have used adircommand to find filenames) and also because the mask contains)(which would close thefor…(unless quoted or escaped).So - why use
* (2).wav? The(2)file must exist for the process to be executed, so all we need to do having obtained those names is to find out whether the*exists, then assemble the requiredsoxcommand.Next,
FOR /f %%y IN ("%%e") DOuses the defaulttokens=1and Space delimiter to assign the*part to%%y.Then we test whether
%%y.wavexists, and if it does, executesoxwith parameters constructed from the parts.