Solved

Help with copy of files using list

Posted on 2014-10-01
8
168 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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.
This is about my first experience with programming Arduino.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

708 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

20 Experts available now in Live!

Get 1:1 Help Now