Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude destination files/directories form robocopy?

Tags:

robocopy

I have a deploy process that is currently using this robocopy command:

robocopy [source] [destination] /MIR /XF [file pattern] /XD [directory pattern]

The [destination] may have additional files or directories added to it outside this process that the [source] does not. The /MIR flag is present because if I add files or directories to [source] I want them to appear in the [destination]. Also, if I remove a file/directory from [source] that exists in [destination] I want to remove that from [destination]. However, this will also remove any of the new files/directories that may have been added to [destination].

The /XF and /XD flags appear to only restrict the source files/directories. Is there a corresponding way to exclude destination files from the copy? Something to indicate "When doing \MIR don't delete directories starting with the string 'new'," for example.

like image 702
theJBRU Avatar asked Sep 13 '25 00:09

theJBRU


1 Answers

Should have run more tests before asking. It appears that amending the command to be:

robocopy [source] [destination] /MIR /XF [file pattern] /XD [source directory pattern] "new*"

Does, in fact, ignore directories in the [destination] that have "new" as the start of their name.

like image 131
theJBRU Avatar answered Sep 16 '25 09:09

theJBRU