Variable Scope in XP Batch Files

  • Thread starter Thread starter cptTech
  • Start date Start date
C

cptTech

I have the following piece of code in my batch file:

----------------------------
set getdate=true
for /f "usebackq skip=5 tokens=1" %%H in (`dir %%G`) do (
if %getdate%==true echo ^<i^> %%H^</i^> >> %filename%
set getdate=false
)
----------------------------

But when it gets to the IF statement inside the FOR loop, CMD tells me
that %getdate% is empty! My guess is that the %getdate% variable
inside the FOR loop is somehow different then that in the parent code.

Is there any way to reference this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top