Page 1 of 1

Need help with variable substitutions and FOR loop

Posted: 19 May 2010 15:16
by Graffic
---

Re: Need help with variable substitutions and FOR loop

Posted: 19 May 2010 16:01
by aGerman
Lot of stuff.

1st)
To substitude something inside a for loop You can't use the dynamic variables (like %%a). You have to use regular variables and the call trick.
Eg. substitude a by b

Code: Select all

@echo off &setlocal
for %%a in (a1 a2 a3 a4) do (
  set "temp=%%a"
  call set "temp=%%temp:a=b%%"
  call echo %%temp%%
)
pause


2nd)
You should find the subfolder name in %~nx1 so you could combine this to the file name.

Hope that helps
aGerman

Re: Need help with variable substitutions and FOR loop

Posted: 19 May 2010 16:18
by Graffic
Please bear with me as I'll need a good bit of hand-holding.. You're referring to the new FOR loop which would enclose the code in STEP 03 and also account for random # of files being processed, right? Forgive me but I don't understand the code you've posted. :(

graf

Re: Need help with variable substitutions and FOR loop

Posted: 19 May 2010 16:31
by aGerman
I see.
But it's 0:30 in Germany and I have to sleep some hours. Tomorrow I will try to understand your entire code. Think I can do some more for you.

Regards
aGerman

Re: Need help with variable substitutions and FOR loop

Posted: 19 May 2010 17:42
by Graffic
---

Re: Need help with variable substitutions and FOR loop

Posted: 20 May 2010 11:19
by aGerman
I can't try it because I don't have your tools.

Code: Select all

@echo off &setlocal
FOR /R %%D in (.) DO CALL :recursive2 "%%D"
GOTO :eof


:recursive2
FOR %%F IN (%~1\*.tga) DO composite -compose Dst_over -tile pattern:checkerboard -size 10x10 "%%F" "%%~nF.png"

montage *.png -background "transparent" -type TrueColorMatte -geometry 120x120+4+4 -tile 4x3 Grid.png

FOR /f "delims=" %%a IN ('dir /a-d /b *.tga') DO CALL :recursive3 %1 "%%a"

del *.png
del *.tga
GOTO :eof


:recursive3
setlocal
FOR /f "delims=- tokens=1*" %%I in ("%~n2") do set "number=%%J"
IF NOT DEFINED number (
  GOTO uBound12
) ELSE (
  GOTO lBound13
)

:uBound12
convert e:\img_output\IM_RSRC\Header.tga %~2 -append ^
  e:\img_output\IM_RSRC\Backdrop.tga +swap -composite ^
  e:\img_output\IM_RSRC\Copyright_Grid.tga -composite ^
  %~1\%~nx1Sheet.tga
endlocal
GOTO :eof

:lBound13
convert e:\img_output\IM_RSRC\Header.tga %~2 -append ^
  e:\img_output\IM_RSRC\Backdrop.tga +swap -composite ^
  e:\img_output\IM_RSRC\Copyright_Grid.tga -composite ^
  %~1\%~nx1Sheet-%number%.tga
endlocal
GOTO :eof


Regards
aGerman