inetquestion
2012-08-09 03:36:37 UTC
when running the command below such as: test.bat res*stu*.pdf
Why does the for loop set the value of XXX, but in the next for loop it fails to set the value of 'attachment'?
============
@echo off
set XXX=
set attachment=
touch "resilxxoo stuff.pdf"
for %%I IN (%1) do set XXX="%%I"
echo Attachment-A: %XXX%
::::::::::::::::::::::::::::::::::::::
:: Process command line params
::::::::::::::::::::::::::::::::::::::
:while
IF "%1" == "" (GOTO wend)
If /I "%~x1" == ".pdf" (
for %%I in (%1) do set attachment="%%I"
echo 1: %1
echo Attachment-B: %attachment%
shift
)
@GOTO while
:wend
Why does the for loop set the value of XXX, but in the next for loop it fails to set the value of 'attachment'?
============
@echo off
set XXX=
set attachment=
touch "resilxxoo stuff.pdf"
for %%I IN (%1) do set XXX="%%I"
echo Attachment-A: %XXX%
::::::::::::::::::::::::::::::::::::::
:: Process command line params
::::::::::::::::::::::::::::::::::::::
:while
IF "%1" == "" (GOTO wend)
If /I "%~x1" == ".pdf" (
for %%I in (%1) do set attachment="%%I"
echo 1: %1
echo Attachment-B: %attachment%
shift
)
@GOTO while
:wend