I'm moving jobs away from a windows box, one task it runs is the following simple robocopy command: robocopy "c:\source\path" "c:\destination\path" /s /mot:10 /NP /M

The /M flag enables me to only move new files, then it sets the archive attribute.

Is there a way I can achieve this in bash? I'm aware that rsync has the --ignore-existing switch, but this isn't suitable, as the data is going to be removed from the destination folder once copied. So wouldn't this copy the file over again once removed from the destination path?

Is there a way, to write a list of copied files to a log, and have that log queried to see if it exists before copying the new file to the destination path?


  • 1
    You'd have to write a small script that 1) performs an rsync 2) adds the list of moved files to an exclude file to use the next time you do an rsync, using the --exclude-from option. That may take some experimenting to do right. – Jos May 9 '17 at 9:27
  • @M.Becerra The way I read it, these file may not exist any longer, but OP doesn't want these files to be moved twice. – Jos May 9 '17 at 9:29
  • Yes that' correct, they won't exist in the destination directory for long and I won't want them moved twice. I'll have a play with --exclude-from thanks – jahcrispy May 9 '17 at 10:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.