[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Easy Batch File Question

Posted on 2002-04-02
4
Medium Priority
?
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 800 total points
ID: 6914079
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
ID: 6914097
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
ID: 6914139
0
 
LVL 1

Author Comment

by:canadiense
ID: 6914145
Looks good!  Tried 'er out and it works great.

Thanks,

Muito obrigado!

Chris.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

649 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