Any other suggestions, let me know.
I'd like to resort to your first approach figuring out how to escape DOS special symbols from the command option if used from inside a BAT script:- As you've already noticed, each occurrence of "%" has to be substituted by "%%".
- Secondly, double quotes (") have to be preceded by a backslash (\). Substituting them by single quotes (') does not work, as you've already figured out.
The following script "r.bat" seems to do the job:
@echo off
r128gain --preamp=-1.0 "--command=sox \"%%TRACK%%\" \"%%DN%%\%%BN%%-24db.wav\" gain %%TGDB%%" %1 -o "H:\tmp\Folder with Space in Name\Output Subfolder with Space in Name"
Following is a test session (please note that the argument to the script is surrounded by double quotes):
H:\>r "H:\tmp\Folder with Space in Name\Input Subfolder with Space in Name\*"
SoX successfully loaded.
FFmpeg successfully loaded.
analyzing ...
01 Track 1 with Space in Name.flac (1/8): -12.7 LUFS, -11.3 LU (peak: 0.956400: -0.4 dBFS, range: 2.6 LU)
02 Track 2 with Space in Name.flac (2/8): -12.7 LUFS, -11.3 LU (peak: 0.867426: -1.2 dBFS, range: 2.9 LU)
03 Track 3 with Space in Name.flac (3/8): -13.4 LUFS, -10.6 LU (peak: 0.987564: -0.1 dBFS, range: 6.5 LU)
04 Track 4 with Space in Name.flac (4/8): -12.7 LUFS, -11.3 LU (peak: 0.987406: -0.1 dBFS, range: 2.3 LU)
05 Track 5 with Space in Name.flac (5/8): -12.7 LUFS, -11.3 LU (peak: 0.919231: -0.7 dBFS, range: 2.3 LU)
06 Track 6 with Space in Name.flac (6/8): -12.5 LUFS, -11.5 LU (peak: 0.829128: -1.6 dBFS, range: 3.6 LU)
07 Track 7 with Space in Name.flac (7/8): -13.0 LUFS, -11.0 LU (peak: 0.976282: -0.2 dBFS, range: 4.2 LU)
08 Track 8 with Space in Name.flac (8/8): -14.5 LUFS, -9.5 LU (peak: 0.899243: -0.9 dBFS, range: 3.1 LU)
ALBUM: -12.9 LUFS, -11.1 LU (peak: 0.987564: -0.1 dBFS, range: 3.8 LU)
writing ...
01 Track 1 with Space in Name.flac (1/8) ... done.
02 Track 2 with Space in Name.flac (2/8) ... done.
03 Track 3 with Space in Name.flac (3/8) ... done.
04 Track 4 with Space in Name.flac (4/8) ... done.
05 Track 5 with Space in Name.flac (5/8) ... done.
06 Track 6 with Space in Name.flac (6/8) ... done.
07 Track 7 with Space in Name.flac (7/8) ... done.
08 Track 8 with Space in Name.flac (8/8) ... done.
H:\>dir "H:\tmp\Folder with Space in Name\Output Subfolder with Space in Name"
Datenträger in Laufwerk H: ist DATA
Volumeseriennummer: B4EC-4972
Verzeichnis von H:\tmp\Folder with Space in Name\Output Subfolder with Space in Name
31.03.2012 08:52 <DIR> .
31.03.2012 08:52 <DIR> ..
31.03.2012 08:51 38.984.444 01 Track 1 with Space in Name-24db.wav
31.03.2012 08:51 40.007.564 02 Track 2 with Space in Name-24db.wav
31.03.2012 08:51 47.204.684 03 Track 3 with Space in Name-24db.wav
31.03.2012 08:51 74.810.108 04 Track 4 with Space in Name-24db.wav
31.03.2012 08:51 47.282.300 05 Track 5 with Space in Name-24db.wav
31.03.2012 08:51 44.563.388 06 Track 6 with Space in Name-24db.wav
31.03.2012 08:52 53.362.220 07 Track 7 with Space in Name-24db.wav
31.03.2012 08:52 33.897.068 08 Track 8 with Space in Name-24db.wav
8 Datei(en), 380.111.776 Bytes
2 Verzeichnis(se), 206.937.473.024 Bytes frei
H:\>_
Edit: If you throw away true peak and loudness range anyway, you should consider using the "--fast" option.