.bat wont run

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
eXceii
Posts: 4
Joined: 2011-04-19T16:41:11-07:00
Authentication code: 8675308

.bat wont run

Post by eXceii »

I am a huge coding novice and I was hoping someone might be able to tell me why my batch code will not run.

I am trying to pass many .jpg's into the run.bat and have the run.bat check the .jpg's name and path against a text file containing the names of .jpg's that have already been processed.

I am guessing it might have something to do with scope but to be honest I have no idea. (The resize.bat works by itself btw).

(run.bat)

Code: Select all

SETLOCAL EnableDelayedExpansion
%%~d1
CD %%~p1
SET EXISTS=0

FOR %%A in (%%*) DO (
	FOR /F %%I in (piclist.txt) DO (
		IF %%A=%%I (
		SET EXISTS=1
		)
	)
	IF EXISTS=1 (
	SET EXISTS=0
	) ELSE (
	CALL resize.bat "%%A"
	ECHO %%A>>piclist.txt
	)
)

(resize.bat)

Code: Select all

convert -size 744x388 xc:#e5e5e5 composite_744x388.png

convert %1 -thumbnail 724x328 large_tmp.jpg

convert large_tmp.jpg ^( +clone  -background black  -shadow 50x3+5+5 ^) +swap ^
          -background none   -layers merge  +repage   shadow_tmp.png

composite -gravity center shadow_tmp.png composite_744x388.png "%~n1_large.jpg

DEL large_tmp.jpg
DEL shadow_tmp.png
DEL composite_744x388.png
eXceii
Posts: 4
Joined: 2011-04-19T16:41:11-07:00
Authentication code: 8675308

Re: .bat wont run

Post by eXceii »

Anyone?
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: .bat wont run

Post by whugemann »

Your question is more about Windows Batch file processing than about ImageMagick. And seeing this code doesn't make me believe that you are a coding novice.

If you pass the filenames via the command line, it should however be
FOR %%A in (%*) DO
with a single percent sign, see http://www.imagemagick.org/Usage/windows/#arbitrary.

Why are you cross-checking the files against a list that you even modify during the batch processing? This seems unnessessary to me and, moreover, needlessly complicating matters.

Wolfgang Hugemann
Wolfgang Hugemann
eXceii
Posts: 4
Joined: 2011-04-19T16:41:11-07:00
Authentication code: 8675308

Re: .bat wont run

Post by eXceii »

[quote="whugemann"][/quote]

Thanks for the help but omitting the % still didn't allow the batch to run.

Also the reason I am cross checking the .jpg's against a list of names then adding to the list is because I am using a system that will pass the same jpg's to the batch file as well as new ones. I only want the new ones to be processed. I am unable to change the system so I have to accommodate in my code.

I would very much appreciate any suggestions you might have on a better way of doing things.

Cheers.
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: .bat wont run

Post by whugemann »

I would check whether the filename is in the list via

Code: Select all

TYPE piclist.txt | FIND %%I 
IF ERRORLEVEL ...
ERRORLEVEL will only be zero if the string is found.

This seems to be an easier approach to the problem.
Moreover, I would recommend that you develop the batch file step by step, first testing the cross-checking procedure and then introducing the ImageMagick command.

You cannot really expect other people to read some complex code and figure out what's wrong with it. You have to pose more specific questions.

Wolfgang Hugemann
Wolfgang Hugemann
eXceii
Posts: 4
Joined: 2011-04-19T16:41:11-07:00
Authentication code: 8675308

Re: .bat wont run

Post by eXceii »

Thanks whugemann, I have decided to use PHP for my conditionals now but I am sure your suggestion is exactly what I needed.

Also thanks for the tip of a step-by-step approach, that was my intentions to begin with.
Post Reply