5

So, I'm trying to rescale a bunch of images at once with a program called ImageResizer, and the command forfiles.

But since I have to use quotation marks for both, the command itself, and an argument inside of it, that won't work:

ERROR: Argument/Option invalid- '4x /save @FILE'.

How do I handle those two strings in batch? I found some similar questions, but I didn't get it to work.

Here's my code:

@echo off
cd %~dp0
cd gfx
forfiles /s /m *.png /c "C:\Users\Manu\Desktop\NeuerOrdner\ImageRes.exe /load @FILE /resize auto "XBR 4x" /save @FILE"
pause
aschipfl
  • 33,626
  • 12
  • 54
  • 99
Scayze
  • 75
  • 1
  • 10

2 Answers2

3

this is a bug in forfiles.And you need to encode quotes with 0x22

you can try like this:

@echo off
setlocal
set "path=%path%;C:\Users\Manu\Desktop\NeuerOrdner\" 
cd %~dp0
cd gfx
forfiles /s /m *.png /c "ImageRes.exe ImageRes.exe /load @FILE /resize auto 0x22XBR 4x0x22 /save @FILE"
endlocal
pause

or

@echo off
cd %~dp0
cd gfx
forfiles /s /m *.png /c "C:\Users\Manu\Desktop\NeuerOrdner\ImageRes.exe  /load @FILE /resize auto 0x22XBR 4x0x22 /save @FILE"
pause

(additional space after imageres.exe)

Community
  • 1
  • 1
npocmaka
  • 55,367
  • 18
  • 148
  • 187
0

FORFILES recognizes \" as the way of escaping inner ". So try this:

forfiles /s /m *.png /c "C:\Users\Manu\Desktop\NeuerOrdner\ImageRes.exe /load @FILE /resize auto \"XBR 4x\" /save @FILE"
ePandit
  • 2,905
  • 2
  • 24
  • 15