Bat file to move files/sync folders

steven
steven used Ask the Experts™
on
We are trying to write a bat file that will keep two directories/folders up to date, but we only want the newest files moved i.e. so one directory has 110 files the other 100, we only want to move the 10 missing files.    At this time the bat file copies all files over, which is taking much time as the directory has many files.    Can anyone help?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer

Commented:
Take a look at robocopy.

If you really want to move the files, then I don't see a problem in doing an "overwrite" here. Moving files is a "cheap" operation in comparison to copying, cause only the directory entries in NTFS are adjusted.
stevendeveloper

Author

Commented:
At present there are 85000 files will it quickly move the files?
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Can you clarify a bit more about what you need to accomplish.  In your question, you mention "newest", but then you also mentioned "missing" as the files you want to copy.  More specifics would be helpful.  Think about all cases:

files that don't exist in source but do in destination
files that don't exist in destination but do in source
files newer in source
files older in source
files that are exactly the same
do you just want to compare based on last update time, or actual content
etc...


»bp
stevendeveloper

Author

Commented:
Ok sorry I would like to keep the directories in sync, but do not want to move all files each night, only ones that don't exist in the destination..
IT / Software Engineering Consultant
Top Expert 2016
Commented:
Sounds like ROBOCOPY with the /MIR option may be what you are looking for.


»bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial