Cannot use a FOR LOOP on a batch file

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
troller
Posts: 12
Joined: 2014-04-21T14:52:51-07:00
Authentication code: 6789

Cannot use a FOR LOOP on a batch file

Post by troller »

Hi everybody!
I have a batch file (MS-DOS) containing inside multiple FOR LOOPS with variables %%a or equivalent and strings like this:

for /F "usebackq tokens=1,2 delims=,:" %%X ^
in (`%IM%convert convert RPS.bmp txt:^|find "%colorRPS%"`) ^
do (
set /A sigXRPS+=%%X
set /A sigYRPS+=%%Y
set /A nCountRPS+=1
)

I need to process, in the same way, a set of images, all named for example "test1.bmp", "test2.bmp", "test3.bmp"... etc etc... say like 30 pictures.

I tried to put a big FOR %%a IN (test*.bmp) DO (...) and put inside all my batch code, but I can't find a way of making it work...

inside the batch code there are some variables that are defined along the way and echoed later, as well as names of output files (both images and text files) that are created and then erased or combined.

Why is my FOR LOOP not working?

Any suggestions?

thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cannot use a FOR LOOP on a batch file

Post by snibgo »

troller wrote:Why is my FOR LOOP not working?
Difficult to say without seeing it. If you set a variable within a loop then references need !this! instead of %this%, and you need enabledelayedexpansion. Commands inside loops that contain parentheses needs to have them escaped or quoted.
snibgo's IM pages: im.snibgo.com
Post Reply