/build/static/layout/Breadcrumb_cap_w.png

VBscript or BATscript to comapre and copy files within 2 folders .

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
  • sometime folder A having subfolder, so compare with folder A as well as subfolder and copy as it is subfolders in folder B. - vjay 10 years ago
  • Er...heard of XCopy or RoboCopy? - anonymous_9363 10 years ago

Answers (2)

Posted by: olditguy 10 years ago
Second Degree Blue Belt
0

RoboCopy SourceDIR TargetDIR /MIR

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

Posted by: devious 10 years ago
Senior White Belt
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

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ