Solved

Help with copy of files using list

Posted on 2014-10-01
8
183 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
An article on effective troubleshooting

756 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