Solved

Help with copy of files using list

Posted on 2014-10-01
8
175 Views
Last Modified: 2014-10-02
@echo off
SET destfolder=c:\backup
FOR /F "delims=" %%a IN (c:\backup\output.txt) DO COPY "%%a" "%destfolder%\%%~nxa"

The above takes output.txt which has hundreds of lines of filenames/paths that look like this
F:\active\C com\Drawings\oh Drawings\a100s\A101.bak
and then copies all the files into c:\backup

I now need to do the opposite, so take files, and put them back in the directory.  So copy all files located in c:\backup, use the output.txt to tell it where to place each of the files.

To get my output.txt I did
 xcopy f: /l /s /d:09-22-2014 > output.txt
So its a list of all files that have changed...  

An ideal command would be  xcopy f: /l /s /d:09-22-2014 > \\newserver\f_share\ - so have it copy all files newer than X and paste to a remote location (or mapped drive etc.)
0
Comment
Question by:rhwimmers
  • 4
  • 3
8 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 40356386
On the mobile at no. So not typing out complex script, but you can use a for command to read your xcopy output:

For /f "tokens=*" %%a in ('xcopy ....') Do copy .

Will try and look back later on of.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40356388
Just realised actually my you aren't copying files into directory structure, just flat? How do you know there us only one file of each name?  You would have to use a find command for each entry to get the path from your text file, unless you did something like write a text file per file say, filename.ext.dir containing the proper dir name say, or kept them in dir structure under backup?
0
 
LVL 1

Author Comment

by:rhwimmers
ID: 40356405
I really just want to copy all files in this output.txt and paste into z:\test (mapped drive) - overwriting files
0
Being driven mad by email signature updates?

Having to make a change to your users’ email signatures, yet again? Feel like your head is going to explode? Rely on an Exclaimer email signature management solution to make the process simple!

 
LVL 1

Author Comment

by:rhwimmers
ID: 40356409
keeping the structure the same..  so output.txt has

f:\filepath\path\filename.txt

I want everything in the above file to go to the Z drive, in the same path, like
z:\filepath\path\filename.txt

I can easily take output.txt and find/replace so I then have a source file

f:\filepath\path\filename.txt
and a destination file
\\servername\filepath\path\filename.txt

If thats easier
0
 
LVL 1

Author Comment

by:rhwimmers
ID: 40358061
final command ended up being

(FOR /F "delims=" %%a IN (c:\backup\output.txt) DO echo f | xcopy /d "%%~a" "z:%%~pnxa") > c:\backup\log.txt 2>&1

copy files in list and paste to remote destination only changing new files, and not removing any old files.
0
 
LVL 1

Author Closing Comment

by:rhwimmers
ID: 40358063
Thanks for the help!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40358073
Glad it worked out in the end (we exchanged some emails directly too along the way)

Steve
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

863 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

19 Experts available now in Live!

Get 1:1 Help Now