Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embarrassing, but I need some batch file advice! 1

Status
Not open for further replies.

mudskipper

Technical User
Joined
May 29, 2002
Messages
600
Location
US
I see a bunch of batch file questions in this forum so I thought that I would post here.

Although it pains me to admit it, I could use some help. I have been searching through tons of DOS util sites to find a freeware program that will let me copy utilizing a source file.

For example, I first get the files + path into a file

dir err?????.txt /s /b >> source.txt

Contents of source.txt now reads:

c:\blah\blah\err_1.txt
c:\blah1\blah1\err_2.txt


Now I need to copy both log files to c:\logfile. Essentially, it might look something like this

copyutil source.txt c:\logfile

Now dir c:\logfile should show me
err_1.txt
err_2.txt


Anybody know of one off the top of your head? Mudskipper
___________________________________________________________________________________

Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
 
Mudskipper,

Do you mean the logfile would contain the contents of the other files - appended in turn (to an originally empty file)?

I was going to suggest posting in win2k forum - Jocsta's pretty nifty with batch files - but he's not been on for a couple of weeks.
 
I am sorry, no. I should have specified that. it should read c:\logfile
Just in case I am not clear -- I want to pass the files that are listed inside of source.txt to a copy command that will in turn put them all inside of one directory (namely c:\logfile\).

Am I doing this the hard way? I feel like I am missing something really basic here! LOL

I must admit that the actual batch file is huge--I was having trouble simplifying what I was asking so that you didn't have to read through my bad scripting!! Mudskipper
___________________________________________________________________________________

Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
 
I think you want a For statement - so for each entry (inputfilename) in your input file, batch will perform 'copy inputfilename c:\logfile'.

I noticed Jocsta supplied a number of these (more complicated than yours) - so I'll leave you to work out the syntax (I'm going to bed, its geting late here in Uk!)
 
Thanks a bunch--I'll look up some of his threads and see what I can find! Mudskipper
___________________________________________________________________________________

Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
 
Geez. Yup, I was trying to make it too hard. Using Jocsta's FOR statements (and the good ol' help files) I was able to get going! Thanks, wolluf, for pointing me in the right direction! Mudskipper
___________________________________________________________________________________

Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
 
In fact, I suppose that I should post the answer in case anybody else ends up looking for similar issues.

for /F %%I in (c:\whatever\source.txt) do copy %%I c:\logfile\ Mudskipper
___________________________________________________________________________________

Groucho said it best- "A four year-old child could understand this! Quick! Run out and find me a four year-old child: I can't make heads nor tails out of this!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top