Solution to copy only new files from location a to b

0

For a solution, I'm looking for a basic tool that can copy files from location A to B. There is one major rule for this:

Only files in location A that where not there the last time the tool ran, need to be copied to location B.

I've looked into Robocopy. I saw the option to copy files from A to B. However, in location B, the files are deleted after they have been used. So robocopy keeps copiying them every time. I only need to have new files in location B.

Hope this is clear and there is a solution for my challenge.

Sunfile

Posted 2020-02-21T10:38:34.800

Reputation: 1

1This won't work with most tools if you don't keep a history as you're deleting the files in the destinations. Alternatively you'd have to be selective about the timeframe and e.g. only run once every so often and only copy files since the last run. Which is very different from a regular sync. – Seth – 2020-02-21T10:52:15.860

Answers

0

Files on Windows have an 'Archive' attribute which is set on creation and every time the file is modified.

You can use Robocopy with the /m option to only copy those files which have +A set and automatically unset it after copying. The next time you run robocopy /m it will skip the already-copied files.

(Note that +A is also set when the file is moved or renamed – but not when the parent directory is moved or renamed.)

user1686

Posted 2020-02-21T10:38:34.800

Reputation: 283 655

this solution did work locally. Does this require write-access on file location A side to change attribute status? – Sunfile – 2020-02-21T15:23:24.003

Yes it does, although if you're asking in terms of NTFS ACLs then "write attributes" can be granted independently from "write data". – user1686 – 2020-02-21T15:31:31.837