none
Robocopy /move deletes also parent folder RRS feed

  • Question

  • Hi everybody,

     

    I have the following problem

    I want to move all data, files and subfolders in folder c:\test  to folder c:\dump, but i do not want to remove the test folder itself (the parent folder)

    the command:

    robocopy c:\test\ c:\dump\ /s /e /move

    but this deletes also my test folder. /move options works ok but wipes the parent also.

     

    please help

    thx in advance

     

    is there any way to fix this ??

     

    Thursday, August 25, 2011 8:21 AM

Answers

  • Hi,

     

    but i want empty the test folder. Actualy, want i really want is delete the contents of the test folder.

    But with del or rd command is not possible because del deletes files (*.*) but del *.* /s does not wipe folders or subfolders. Rd command deletes directories does not work with *.* If you run rd c:\test\ /s it wipes also the test directory. That's why i am using robocopy. .. any suggestions? The Test directory is just a test directory..What we have actually have is a network share with permissions set. I could wipe out the network share and then recreate (with batch file) it but then the permissions should be applied again... ufff .. we want just empty the folder every Saturday ..(that is the easy part)

     

    please help

    • Marked as answer by Mister007 Thursday, August 25, 2011 9:06 AM
    Thursday, August 25, 2011 9:01 AM

All replies

  • Hi,

    Do not use the /MOVE Switch

    USe /copyALL

    http://ss64.com/nt/robocopy.html


    Disclaimer: This posting is provided AS-IS with no warranties or guarantees and confers no rights. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, August 25, 2011 8:29 AM
  • Hi,

     

    but i want empty the test folder. Actualy, want i really want is delete the contents of the test folder.

    But with del or rd command is not possible because del deletes files (*.*) but del *.* /s does not wipe folders or subfolders. Rd command deletes directories does not work with *.* If you run rd c:\test\ /s it wipes also the test directory. That's why i am using robocopy. .. any suggestions? The Test directory is just a test directory..What we have actually have is a network share with permissions set. I could wipe out the network share and then recreate (with batch file) it but then the permissions should be applied again... ufff .. we want just empty the folder every Saturday ..(that is the easy part)

     

    please help

    • Marked as answer by Mister007 Thursday, August 25, 2011 9:06 AM
    Thursday, August 25, 2011 9:01 AM
  • Hi,

    DOes you test folder have any sub directories or only files???

    If it contains only files then use /MOV switch

     


    Disclaimer: This posting is provided AS-IS with no warranties or guarantees and confers no rights. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, August 25, 2011 9:58 AM
  • One workaround is to create a simple text file and save it into the parent directory you want to preserve. "Hide" it with an attribute if that's better, but only for aesthetics. Then in the ROBOCOPY /MOVE command line, add

    /XF [path]\yoursimple.txt

    into the chain of flags. This will exclude /MOVEing that file, which will stop ROBOCOPY from deleting the parent folder. Tweak the simple.txt file's security or share permissions if you need to prevent someone from deleting or renaming the file while it sits there anchoring the parent folder in place.

    Friday, January 24, 2020 11:54 PM