robocopy /MIR - don't delete desktop.ini in destination
Asked Answered
M

3

5

I want to sync folders between two computers, one with XP and one with Vista. I want the two folders mirrored, except for security settings and folder settings. It is my understanding that /MIR switch will delete any 'extra' files in the destination folder, which would include the desktop.ini files. I can avoid copying desktop.ini files with /XA:SH How can I prevent robocopy from deleting the destination desktop.ini files?
If I have to do any extra scripting, I prefer PowerShell. But I hope robocopy can do it on its own.

Thanks.

Manley answered 7/3, 2012 at 17:49 Comment(0)
G
9
/XF desktop.ini

Will exclude Desktop.ini (from copy or purge).

Gustation answered 8/3, 2012 at 8:5 Comment(0)
R
2

Replace the /MIR switch with /E, and don't use the /PURGE parameter.

Explanation: /MIR is the equivalent of using /E /PURGE, so by using /E without /PURGE, you achieve the results you desire.

Ryter answered 7/3, 2012 at 21:47 Comment(2)
Thanks, but I do want to purge destination of any extra files, except for 'desktop.ini'. So what I need is something like an exclude filter on the purge action. Of course, if the whole subfolder needs to be removed from destination, because it does not exist in source, then 'desktop.ini' should be removed along with it. Maybe I am asking too much here, but it would be nice to have this.Manley
Yeah, I don't think you'll be able to do a conditional purge. Sorry mate.Ryter
S
0

Create a bat file so you can mirror the source at the destination and later once the mirror process is finish erase the files you desired. For example:

robocopy SOURCE DEST /E /PURGE or /MIR or /E command to erase recursively (test the command before running at production): del /s DRIVe:\DESTINATION\desktop.ini

Hope this helps, Luis

Squally answered 1/4, 2015 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.