+44 (0)20 3051 3595 | info@coeo.com | Client portal login

How to prevent Robocopy from hiding your files and how to fix it when it does

Edward Harrison

I recently had a scary moment at a customer when I was testing to see how long it would take to copy a data file between two of their disks using Robocopy and an old and relatively small backup file. If you haven't heard of Robocopy, then you should look into it as a command line (cmd) tool for copying your files quickly; it has been much quicker than copying and pasting backup and data files around in my experience. I ran the copy without specifying any specific attributes with the expectation that it would just do what it was told and nothing else. Below is an example of what I did using command prompt.

robocopy I:\DATA\ K:\DATA\ DB_DataFile.bak

I ended up stopping it halfway through as it was taking far too long and from what I'd done, I could calculate a rough rate of transfer. However, when I went back onto the disk and tried to go into the destination folder I'd specified (the 'K:\DATA' folder), I found that the folder had apparently disappeared from the drive and was no longer listed as a folder in the K: drive! (That folder contained multiple data files as well).

After quickly testing what had happened, I searched in Windows Explorer for 'K:\DATA' and low and behold, everything was still in there and the folder clearly existed, I just couldn't see the folder from the level above...

After research, I found out that Robocopy has a bug where it alters the attributes of the directory to a system and hidden file. It's been known for quite some time and there are numerous blogs and questions out there on the subject. In order to reverse this change I had to alter the attribute so that the folder should no longer be marked as either a system or a hidden file. These attributes are altered in cmd using the parameters 's' and 'h' respectively, with more information on these parameters from Microsoft if you need it:


Be aware though that you have to change both the hidden attribute and system file attribute in one single go in cmd. If you try to alter these individually then your cmd line will error with either 'Not Resetting System File' (if you tried fixing the hidden attribute) or 'Not Resetting Hidden File' (if you tried to fixing the system attribute).

The Fix

So if this ever happens to you and you need to fix it, use the following command is run in an admin cmd :

attrib -s -h <directory>

e.g. So for us it was :

attrib -s -h K:\DATA

This will change the folder and clears the system and hidden file attribute, bringing it out of hiding and back onto your file explorer.

Preventing it happening again next time

If you're clever and don't want to deal with the problem in the first place (as it's a known bug with Robocopy), when you write out your Robocopy line in cmd, include the minus attributes (A-:SH) at the end of your command. This will stop the destination folder from being hidden and from being turned into a system file, thus preventing the problem ever happening in the first place:



I hope this helps.


Enjoyed this blog? Sign up for monthly updates

Subscribe to Email Updates

Back to top