Solved

Help with copy of files using list

Posted on 2014-10-01
8
179 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing trusted root certificate 12 47
How to add a new profile Windows 10 4 39
Shutdown Inactive Server- Script 4 19
Bat File Script - HELP 2 14
This is about my first experience with programming Arduino.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

776 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