• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

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!

Chris.
0
canadiense
Asked:
canadiense
  • 2
1 Solution
 
SysExpertCommented:
See kixtart.org

or

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

               ServerA
               ServerB
               ServerC

               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

               batch.bat
               ---------

               echo %1

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

               Marcello Cruz
               Brasil (forget the "z")
===
nstall ADSI 2.5 for NT4 from
               http://www.microsoft.com/downloads/search.asp?
               Search for "all downloads" and your OS

               Have VBScript Engine 5.x installed
               http://msdn.microsoft.com

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

I hope this helps !


0
 
cookreCommented:
for /f %%i in (list.txt) do (
...stuff...
)

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


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

Thanks,

Muito obrigado!

Chris.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now