While tweaking my existing RoboCopy scripts, I came across what is either a bug or intended design (pick your poison) where if you copy straight from a root directory to somewhere else, your files will be hidden. It doesn’t even have to be to another root directory. If the source is a root directory, that’s enough to trigger this to happen.
Here’s an example of what a RoboCopy script that experiences this will look like:
robocopy <source (root directory)> <destination>
Practically, this might look like:
robocopy C:\ E:\Backup Folder\
Now this bug/feature doesn’t mean the copy hasn’t taken place – it has – but the files are just .. seemingly gone.
What has happened here is that the files have been marked with the attributes ‘System’ and ‘Hidden’. They are on the drive you specified, but are hidden from normal view.
The Temporary Workaround
If you want to view them, we have to untick the below setting in the destination folder options:

You should now be able to see your files.
The Real Solution
While the above option will show you your files, it will also show folders and files normally hidden by Windows. These are files that we usually aren’t interested in and changing them could corrupt your existing Windows installation.
Clearly we need a more permanent solution.
Thankfully this is relatively painless and can be done by adding another line of code to the end of your RoboCopy script:
attrib -s -h /s /d "E:\Backup Folder\*"
So now the whole line will look like:
robocopy C:\ E:\Backup Folder\ attrib -s -h /s /d "E:\Backup Folder\*"
Let’s take a look at what this means and why it works:
- ‘attrib‘ is short for .. you guessed it, attribute. With this command we are setting the folder attributes that we specify.
- ‘-s‘ means we are removing (hence the minus) the ‘System’ attribute
- ‘-h‘ means we are removing the ‘Hidden’ attribute
- ‘/s‘ means we apply these attribute changes to all files in the specified directory and all its sub-directories
- ‘/d‘ means we apply these attribute changes to all folders in the specified directory and sub-directories
Remember, if there are spaces in your directory path, you will need to surround the path name with quotation marks.
Now once RoboCopy copies over the directories, it will apply the attribute changes (remove the ‘System’ and ‘Hidden’ attributes) to all copied files and folders.
That’s it!
This one was bugging me for a while but I successfully tested it to be working as intended. I hope this can help you too.
References:
- https://superuser.com/questions/783249/remove-attributes-to-sub-folders-and-files
- https://stackoverflow.com/questions/6584402/after-robocopy-directory-files-not-show-on-external-drive
- https://community.spiceworks.com/topic/1933536-robocopy-set-hidden-and-system-attributes-now-wut
- https://technet.microsoft.com/en-gb/library/bb490868.aspx