Share via

Robocopy Switches

Norman Martens 0 Reputation points
2026-05-09T05:17:38.0733333+00:00

I create a folder on an external hard drive called “E Drive”.  Here’s what the attrib command shows:

F:>attrib /d

                      F:#Log

   SH                F:$RECYCLE.BIN

                      F:\E Drive

   SH                F:\System Volume Information

 

Now I run the following Robocopy command:

robocopy E: "F:\E Drive" /XD "E:$Recycle.bin" /MIR /MT:64 /W:5 /TEE /LOG:F:#Log\EDrive.txt

 

Here’s what the attrib command now shows:

 

F:>attrib /d

                     F:#Log

   SH                F:$RECYCLE.BIN

   SH                F:\E Drive

   SH                F:\System Volume Information

 

Notice the “E Drive” folder is now a hidden system folder.  And when I view this drive with Explorer the “E Drive” folder does not show up.

 

How do I prevent Robocopy from doing this?  I must be missing something simple.

Also, a side note. I tried to assign one of the built-in tags. I clicked on the one I wanted but it wouldn't accept it. I had to use the 'manual' method.

 

Thanks

 

Windows for home | Windows 11 | Apps
0 comments No comments

4 answers

Sort by: Most helpful
  1. Norman Martens 0 Reputation points
    2026-05-22T23:54:54.8966667+00:00

    One final question and it might not even be related to RoboCopy but some other systemic issue. How does RoboCopy decide on the sequence when it copies files from source to destination?

    One final question about RoboCopy. And it might not even be unique to RoboCopy but a systemic issue. It deals with the sequence in which RoboCopy copies files.

    Here's the first few lines of a recent log file. I included the very top lines so that you can see precisely what switches I supplied to RoboCopy:


    ROBOCOPY :: Robust File Copy for Windows


    Started : May 21, 2026 6:10:04 PM

    Source : E:\

     Dest : F:\E Drive\
    
    Files : *.*
    
        
    

    Exc Dirs : E:$Recycle.bin

    Options : . /TEE /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /A-:SH /MT:64 /R:1000000 /W:5


        New File  		   16154	E:\4 Auto\NHTSA Vin Decoder.xlsx
    

    100%

        New File  		   24064	E:\80 Tax Returns\FTB Mailing Label.doc
    

    100%

        New File  		   14076	E:\80 Tax Returns\Tell State to Stop Charging for e-filing.docx
    

    100%

        New File  		   27648	E:\#1A Monthly-Current\2 Financial\#Stock Histories.xls
    

    100%

        New File  		   60524	E:\4 Auto\0 Performance\#Template.xlsm
    

    100%

        New File  		   91384	E:\4 Auto\0 Performance\20 Honda Accord.xlsm
    

    0%

    100%

        New File  		  334848	E:\4 Auto\0 Performance\z05 Honda Accord Pearl.xls
    

    100%

    You can see it copies something from E:\4 Auto followed by E:\80 Tax Returns then returns to E:4\Auto. I didn't see any switch options that would allow RoboCopy to control the sequence of copying the files. Then again, there are soooooo many switches I may have overlooked one.

    Thanks.

    Was this answer helpful?

    0 comments No comments

  2. Norman Martens 0 Reputation points
    2026-05-10T18:40:49.0966667+00:00

    Thank you both. My results.

    First, \DCOPY did not work. Got the same results. But, after digging through multiple pages on the web I did discover this little tidbit: \A-:SH. AI did not show me this solution. AI's solution was to add an attrib line to my batch file.

    Here's the new command:

    robocopy E:\ "F:\E Drive" /XD "E:$Recycle.bin" /A-:SH /MIR /MT:64 /W:5 /TEE /LOG:F:#Log\EDrive.txt

    However, I now have a slightly different issue. When I run this exact command (by copying and pasting it into a cmd window) it works fine. But, if I execute the same command from a .bat file, a cmd window pops ups too fast for me to even see it but it does nothing. Is there another switch what will make robocopy stop and leave the cmd window visible because I'm sure there's an error message on it. I found this command in the batch file should keep the cmd window open:

    cmd /K robocopy E:\ "F:\E Drive" /XD "E:$Recycle.bin" /A-:SH /MIR /MT:64 /W:5 /TEE /LOG:F:#Log\EDrive.txt

    but it doesn't. Could it have something to do with administrator rights? When I open my cmd window manually I simply type cmd in the search box. Nor do I press Ctrl + Shift + Enter to launch it. And my registry (Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers) has nothing either. So it appears I'm running the command manually without any special rights. But I'm not sure about the batch file because I can't see the cmd screen.

    Thanks.

    Was this answer helpful?


  3. Carl-L 14,335 Reputation points Microsoft External Staff Moderator
    2026-05-09T10:16:24.3766667+00:00

    Hello Norman Martens,

    Welcome to Microsoft Q&A forum.

    Before we proceed, may I know if you have used the AI assistant suggestions yet? That commands will clear the hidden attributes from the drive, so please do it first.

    Based on the article about Robocopy, if data is copy from the root of the device, the destination will adopt the "hidden" and "system" attribute from it. In this case, can you please try to use this command instead?

    • robocopy E: "F:\E Drive" /XD "E:$Recycle.bin" /MIR /MT:64 /W:5 /TEE /LOG:F:#Log\EDrive.txt /DCOPY:T

    I've tried to keep the change at minimal as possible in this. "/DCOPY:T" can prevent the "hidden" and "system" attributes to be adopted by the destination.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

  4. AI answer

    2026-05-09T05:17:45.8666667+00:00

    Robocopy is not directly changing the attributes of the folder because of the switches shown; instead, the result is that the destination folder ends up with the System and Hidden attributes set. Those attributes can be cleared after the copy, or the folder can be created/normalized before running Robocopy.

    To fix the folder so it is visible again:

    attrib -s -h "F:\E Drive"
    

    This clears the System (-s) and Hidden (-h) attributes from the folder, making it visible in File Explorer again.

    If this happens repeatedly after running the same Robocopy job, add a post-step to your script/batch file to reset the attributes each time:

    robocopy E: "F:\E Drive" /XD "E:\$Recycle.bin" /MIR /MT:64 /W:5 /TEE /LOG:F:\#Log\EDrive.txt
    attrib -s -h "F:\E Drive"
    

    The attrib command is the supported way to manage these attributes on files and directories.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.