Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Attempting to use FOR in DOS .bat file  (Read 3570 times)

0 Members and 1 Guest are viewing this topic.

John_L.

    Topic Starter


    Rookie

    Thanked: 2
    • Experience: Experienced
    • OS: Windows XP
    Attempting to use FOR in DOS .bat file
    « on: February 02, 2012, 09:36:18 AM »
    I have numerous file in the current directory (FILE.1.txt, FILE.1.txt, FILE.3.txt, etc.) and am attempting to use the FOR command in a .bat file as follows:

       FOR /F %%FILE IN ("FILE.*.txt") DO java -cp .;../. myJavaClass CONSTANT %%~nxFILE %%~nFILE.tmp %%~nFILEout.txt

    passing various forms of the filename as parameters to the Java class. Unfortunately, this fails with the message:

       %FILE was unexpected at this time.

    Thanks in advance for any help you may be able to provide.

    Salmon Trout

    • Guest
    Re: Attempting to use FOR in DOS .bat file
    « Reply #1 on: February 02, 2012, 10:18:59 AM »
    Quote
    %%FILE

    FOR variables can only be single letters (A-Z, a-z, case sensitive). Type FOR /? at the prompt to see the documentation.