Run batch on files in a relative folder

Posted by Matteo Cuellar Vega on Super User See other posts from Super User or by Matteo Cuellar Vega
Published on 2012-10-17T16:11:28Z Indexed on 2012/10/17 17:05 UTC
Read the original article Hit count: 362

Filed under:
|
|
|
|

I have a windows batch script that runs a SOX command on various files, but I don't know how to get the batch to run on files in a relative path to that of the SOX executable. Currently all the files are in the root and it outputs to /combined.

The Batch Script:

cd %~dp0
mkdir combined
FOR %%A IN (*.mp3) DO sox static.mp3 %%A "combined/%%~nxA"
pause

I want the script to run the sox command on files in the directory "audiotracks" and output it to the directory "combined". To give you an idea, this would be the desired folder structure:

/root
  sox.exe
  batch.bat
  static.mp3
     /audiotracks
       audio1.mp3
       audio2.mp3
       audio3.mp3
       audio4.mp3
     /combined
       audio1out.mp3
       audio2out.mp3
       audio3out.mp3
       audio4out.mp3

Is this possible, or is there a better method of doing this? Any help would be greatly appreciated. Thanks a lot!

© Super User or respective owner

Related posts about Windows

Related posts about command-line