Solved Copy only new files, or modified files to empty directory

October 1, 2012 at 09:22:05
Specs: Server 2008, 8 gig
I've been finding a ton of scripts to copy only new files and modified files to a directory, but I can't find one that copies only new and modified files into an "empty" directory.

The situation is this. We have access to a read only folder on another server holding XML files. We have a database program thats designed to import xml files, but how it does it is a bit odd.

It looks for any XML files in a specific folder, when it sees them, it imports then deletes them.

I origionally wanted to just use something like freefilesync to keep that folder mirrored. But what would happen is the program would import ALL the xml files, then freefilesync would copy them ALL over again, and the cycle would repeat.

Is there anyway I can run a script or batch that copies ONLY the new or modified XML files to an "empty" directory?


See More: Copy only new files, or modified files to empty directory

Report •

#1
October 1, 2012 at 10:35:41
✔ Best Answer
xcopy /m <source> <destination>
Might copy too many files on its first run, but subsequent runs should be good.

How To Ask Questions The Smart Way


Report •

#2
October 1, 2012 at 13:21:02
That would work the first time, but once the database picks up all the files in the new folder and deletes then, when xcopy /m is ran again, wouldn't it recopy all the files again.

I've been trying to think of a way to flat file this, somehow pick up a directory list w/ modified dates, and use it to base the next copy over on.


Report •

#3
October 1, 2012 at 14:00:06
It copies files with the archive attribute set, and removes the attribute after the copy. The archive attribute is set whenever a file is written to, so as long as nothing writes to the files after the first copy, XCOPY /M will skip over it.

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question