Robocopy - /XA:SH - to exclude system, hidden directories?

mcu picture mcu · Apr 2, 2012 · Viewed 62.9k times · Source

It seems to only work on files. Or am I doing something wrong?

I tried backing a user folder (C:\Users\XXX) in Vista, which has a bunch of hidden/system folders. I used /XA:SHT

The folder 'AppData' is 'hidden' but NOT 'system', so it was not excluded.
Other special folders were 'hidden' AND 'system', and they were excluded. But I am not sure it was because of the /XA:SHT switch I used or some other reason, like permissions.

So, my question is, does /XA applies to directories also, or files only? I hope I don't have to manually enter all the special folders with the /XD switch.

Answer

Lasse Christiansen picture Lasse Christiansen · Sep 4, 2012

According to the documentation /XA does only apply to files.

eXclude files with any of the given Attributes

And just to be sure - I have just tested with Robocopy on Windows 8 RTM and the flag /XA:SH does not make Robocopy ignore hidden directories.

I'm also using Robocopy to do regular backup of my user directory, and to exclude directory junction points ( like My Music ) I use the /XJD flag. Also, to avoid AppData getting copied I use the /XD flag.

My complete list of arguments looks like this: /MIR /FFT /Z /XA:SH /R:0 /LOG+:path\to\logfile.txt /TEE /XJD /NP /XD AppData

For argument reference, please see the documentation.