View Full Version : Resize doesn't work in Batch (.bat) script

23.03.2018, 10:01 AM
Hello, I wonder why the /resize=(X,Y) command does not work in a Windows .bat script like this:

for %%f in (*.bmp) do (
"C:\Programme\IrfanView\i_view32.exe" "%%~nf.bmp" /resize=(2400,1200) /resample /convert="%%~nf.jpg"

In my actual application, a longer script (see below) invokes other tools besides IView as well (that create that .BMP in the first place), that's why I can't economically do the resize with the internal IView batch processing but need to include it in the .bat script. I am just giving the relevant excerpt handling the resizing and jpg conversion with IView here, which ought to work as a standalone batch file but doesn't.

I put the code quoted above in a batch file (text file with ".bat" suffix) placed in the same folder as the files to be processed and double-click it. With just the /convert command everything works as advertised - a JPG of the same dimensions and filename as the input BMP is created in the same folder. As soon as I add the /resize command, the script does nothing at all. If I add other tools before the IView conversion command (as I do in my actual application), and run the script, the /resize effectively kills the whole thing - the DOS window normally echoing the execution of the .bat just flashes for a split-second and then closes down again, while the content of the folder remains unchanged. Not even the preceding commands unrelated to IView are executed.

BTW: The very same command sequence does work on my machine in a simple DOS command line outside a batch file, like:

i_view32.exe "e:\test.bmp" /resize=(2400,1200) /resample /convert="e:\test.jpg"

What am I doing wrong?