Link to home
Start Free TrialLog in
Avatar of ingenia
ingenia

asked on

DOS Batch incremental loop question

At one time I knew how to do this.

I have a list of user names in a text file.

I want a batch file to grab the first username in the txt file and create a directory.  
When it is done, grab number two, etc.

Thoughts?
SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ingenia
ingenia

ASKER

I have a batch file that is doit.bat that has two lines.

----start

@echo off
for /f "tokens=*" %a in (c:\test\users.txt) do md "%a"

----stop

I tried the suggestion from sirbounty.  When I run it, I get:

\test\users.txt) was unexpected at this time.

If I run it manually from a command line, it works.  
Avatar of ingenia

ASKER

is this because it is win2k3 dos?
In a batch file you have to use double percents:

@echo off
for /f "tokens=*" %%a in (c:\test\users.txt) do md "%%a"
You need two %'s in a bat file..

for /f "tokens=*" %%a in (c:\test\users.txt) do md "%%a"

Avatar of ingenia

ASKER

found it.  it needs %% from a batch file, not %

Thanks,
We are all so fast we posted at the same time :)