# Batch file to stamp PDF



## jat421 (Jun 14, 2008)

Hi I have created a batch file that will stamp PDF's. But I seem to be having a issue with one command. Can't figure it out.


```
setlocal ENABLEDELAYEDEXPANSION

set Files=C:\Users\user\Desktop\Stamp Project\Files
set Burst=C:\Users\user\Desktop\Stamp Project\Burst

FOR /f "delims=|" %%a in ('dir /B "%Files%"') DO (

pdftk "%Files%\%%a" burst

move /Y pg*.pdf burst/

FOR /f "delims=|" %%b in ('dir /B "%Burst%"') DO (

START /WAIT "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe" "Burst\%%b"

SET /p stamp=Please enter the stamp date:

convert.exe -colorspace RGB -size 600x1100 xc:transparent -fill red -font Arial -pointsize 10 -gravity NorthEast -annotate +100+10 " %stamp% " stamp1.pdf

convert.exe -colorspace RGB -size 600x1100 xc:transparent -fill red -font Arial -pointsize 10 -gravity SouthEast -annotate +100+20 " %stamp% " stamp2.pdf

pdftk burst/%%b stamp "Stamp1.pdf" output temp/%%b
pdftk temp/%%b stamp "Stamp2.pdf" output output/%%b
)
)
```
Everything works but when I get input from a user and store it on %stamp% variable I can't seem to provide that to convert.exe. It shows up blank as if %stamp% didn't have any value. I have tested the prompt seperately and it seems to work. Any ideas? Thanks!


----------



## Squashman (Apr 4, 2003)

Well I see you are only showing us part of the batch file because your FOR LOOP doesn't have a closing parenthesis.
Anytime you are inside a code block assigning a variable or getting user input you need to use delayed expansion with your variables.


----------



## jat421 (Jun 14, 2008)

sorry yes I have closed the loop just forgot to copy paste it.


----------



## jat421 (Jun 14, 2008)

Thanks Squashman...long time ...I have changed the script as above and still having the same issue ...Any other suggestion ?


----------



## Squashman (Apr 4, 2003)

This should enlighten you.
http://www.robvanderwoude.com/variableexpansion.php


----------



## jat421 (Jun 14, 2008)

Thanks Squashman that did the trick!!!


----------

