Solved

Easy Batch File Question

Posted on 2002-04-02
4
147 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
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 Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 2003 Terminal Server licenses 3 374
Print Server: How to Create it? 1 774
VBScript not processed at Windows 8.1 logon 2 8,039
Referencing a mapped drive 6 141
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…
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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