Solved

Easy Batch File Question

Posted on 2002-04-02
4
143 Views
Last Modified: 2011-04-14
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
Comment
Question by:canadiense
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 200 total points
Comment Utility
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
 
LVL 22

Expert Comment

by:cookre
Comment Utility
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
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
0
 
LVL 1

Author Comment

by:canadiense
Comment Utility
Looks good!  Tried 'er out and it works great.

Thanks,

Muito obrigado!

Chris.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now