0

I have a batch script setup to automatically retrieve a file from a remote FTP server. Part of the requirement is the file will be named with a new datestamp each day, such as "File_90611.csv." I have a command line tool that generates the filename; which is then supposed to be set to a variable using the line below:

for /f "delims=" %a in ('C:\BIN\YesterdayDateStamp.exe') do @set DATESTAMP=%a

The problem is this. This line works fine when run from the command line directly. However, when I put this exact same line in a batch script and run it; I get this error:

\BIN\YesterdayDateStamp.exe') was unexpected at this time.

I REM'ed everything out in the script except the FOR ... IN commands to make sure there wasn't some sort of conflict; but even with this I still get an error.

Been Googling for an answer but have no leads. Any ideas? Any constructive input is greatly appreciated.

Thanks, Frank

1 Answer 1

5

When for is used in a batch file, you need to double the percent signs in front of the variable name.

From for /?:

To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.