i have 2 folders A(sourceDIR) and B(targetDIR). Folder A keepon generating .dll file , some time edit existing files also.

i want to script, when it run will copy all new as well as modified exist files from folder A to B.

any body help.

2 Comments   [ + ] Show Comments

Comments

  • sometime folder A having subfolder, so compare with folder A as well as subfolder and copy as it is subfolders in folder B.
  • Er...heard of XCopy or RoboCopy?
Please log in to comment

Answers

0

RoboCopy SourceDIR TargetDIR /MIR

will mirror the two folders so TargetDIR is the same as SourceDIR.

Answered 02/14/2014 by: olditguy
Second Degree Blue Belt

Please log in to comment
0

Hi,

Here is a script I created to help me do copy jobs:

 

set source=\\YOURSOURCELOCATION

set destination=\\YOURDESTINATIONLOCATION

robocopy %source% %destination% /MIR /E /V /R:1 /W:1 /XO /LOG+:c:\temp\%source%-CopyTo-%destination%.log.txt


All you have to do is change "\\YOURSOURCELOCATION" and "\\YOURDESTINATIONLOCATION"

I also added logging, you need the c:\temp folder or the logs wont right.

/MIR: mirrors source to destination

/E: copy empty folders

/V: verbose for tracking in logs

/R:1: number of retries

/W:1: how long to wait till it retries (1 second)

/XO: is for attributes 

/Log+: so if you run the copy job again it will just append the log file.

 

If you are worried about losing files you can run:

set source=\\YOURSOURCELOCATION

set destination=\\YOURDESTINATIONLOCATION

robocopy %source% %destination% /COPY:DATSO /E /V /R:1 /W:1 /XO /LOG+:c:\temp\%source%-CopyTo-%destination%.log.txt

/COPY:DATSO: will only copy newer files to destination and will not delete files. Basicly just updating files to the newest version.

 

Below is a useful link:

http://technet.microsoft.com/en-us/library/cc733145.aspx

- See more at: http://www.itninja.com/question/move-files-from-one-volume-to-another-while-retaining-permissions#answer-87081

Answered 02/14/2014 by: devious
Senior White Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share