Help with copy of files using list

@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.)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
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?
rhwimmersAuthor Commented:
I really just want to copy all files in this output.txt and paste into z:\test (mapped drive) - overwriting files
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

rhwimmersAuthor Commented:
keeping the structure the same..  so output.txt has


I want everything in the above file to go to the Z drive, in the same path, like

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

and a destination file

If thats easier
rhwimmersAuthor Commented:
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.
rhwimmersAuthor Commented:
Thanks for the help!
Steve KnightIT ConsultancyCommented:
Glad it worked out in the end (we exchanged some emails directly too along the way)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.