Easy Batch File Question

Let's say I've got a list of names in TXT format.

I want to be able to import each name one at a time into a batch file do a whole bunch of stuff with it, and then go on to the next name.

Any info would be appreciated!

Who is Participating?
SysExpertConnect With a Mentor Commented:
See kixtart.org


From: MSCruz  Date: 02/18/2002 06:06AM
  You have a file (teste.txt) with the following content:


               Imagine the only thing you want is to display the contents of the text file in the monitor. You need
               to create a batch file (teste.bat) with the following lines:

               echo off
               for /f "tokens=1" %%aa in (teste.txt) do echo %%a

               If you want to copy the contents of one sharing resource to the local drive, you must change the second
               line to...

               for /f "tokens=1" %%aa in (teste.txt) do copy \\%%a\share c:\backup

               Or if you want to call another batch program that makes a lot of things with each of the servers...

               for /f "tokens=1" %%aa in (teste.txt) do batch.bat %%aa

               Then, create the batch.bat in a way it uses the parameter passed in teste.bat, like this


               echo %1

               That's all. I expect it should be helpfull.

               Marcello Cruz
               Brasil (forget the "z")
nstall ADSI 2.5 for NT4 from
               Search for "all downloads" and your OS

               Have VBScript Engine 5.x installed

               Put the text between -------- in a any.vbs file

I hope this helps !

for /f %%i in (list.txt) do (

In each iteration, %i will have the next line from list.txt

for /f %%i in (list.txt) do (
echo Working with file %1
canadienseAuthor Commented:
Looks good!  Tried 'er out and it works great.


Muito obrigado!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.