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

Author Topic: Script runs in CMD window but not from .bat file  (Read 3834 times)

0 Members and 1 Guest are viewing this topic.

mjump54

  • Guest
Script runs in CMD window but not from .bat file
« on: March 31, 2011, 12:09:21 PM »
I have this string that I use to read a directory of files and then process them according to the second part of the string.

Works fine when i directly enter it into a CMD window, but when writing it into a .bat file, the CMD flashes and goes away without processing the files.  The directory may contain up to 4000 files and what I am trying to do is loop through each file in the directory and insert the data into a Database. And as I said, works fine when I manually paste it into a CMD window, but when running from .bat file, doesn't work.

Here is the string.. any suggestions?

for /f %A IN ('dir /b C:\scripts\files\work\out\*.txt') do call load AR01 -file "C:\scripts\files\work\out\%A" -add

Salmon Trout

  • Guest
Re: Script runs in CMD window but not from .bat file
« Reply #1 on: March 31, 2011, 12:34:58 PM »
At command prompt FOR variables have one percent sign: %A

In a batch script they have two percent signs: %%A