Page 1 of 1

.bat wont run

Posted: 2011-04-19T17:41:36-07:00
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

Re: .bat wont run

Posted: 2011-04-20T08:23:34-07:00
by eXceii
Anyone?

Re: .bat wont run

Posted: 2011-04-21T02:43:09-07:00
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

Re: .bat wont run

Posted: 2011-04-21T11:30:22-07:00
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.

Re: .bat wont run

Posted: 2011-04-22T04:46:35-07:00
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

Re: .bat wont run

Posted: 2011-04-23T15:19:35-07:00
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.