Simple task:
Move all the content of the directory c:\Users\files\Desktop\test 2
to c:\Users\files\Desktop\test 1
C:\admin\temp>robocopy "c:\Users\files\Desktop\test 2" "c:\Users\files\Desktop\test" *.* /S /MOVE
Sounds reasonable, but now, the directory c:\Users\files\Desktop\test 2
gets removed too. Is there a switch to just move the CONTENT without the removing directory itself?
I have been trying to do the same from a network share.
Here are my findings and solution from tests on a Windows 7 machine.
Suggestion:
Problem: Moves source folder.
Suggestion:
Problem: Still moves source folder.
Suggestion:
Problem: Leaves empty folder structure behind in source folder.
Working solution:
First two lines move top level files, the third moves folders. Note the double %% is for usage in a batch file, pasting into a command line needs these changed to a single percentage mark.
~nxi in the destination is a FOR SUBSTITUTION VARIABLE ( See FOR /? ) where ~nxi represents the name and extension of the item currently being looped through.
Robocopy defaults to RETRY A MILLION times and WAIT 30 SECONDS between each try, so you may wish to add /R:1 /W:1 to the robocopy arguments.
Have you tried the /MOV option?
F:>robocopy /?
ROBOCOPY :: Robust File Copy for Windows
Started : Fri Aug 06 11:51:26 2010
You can do this by creating a placeholder file in the directory you don't want to delete, and then instructing robocopy to exclude the file using /XF
Since the file is excluded, it won't get moved, and the directory won't get deleted.
For details, see that other site: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_24306678.html (and scroll down to the bottom, etc, etc).
I ran into the same problem and just fixed it with the
MKDIR
command after I have run therobocopy
.You want to move all the content of a given folder, so that ONLY the parent folders is left behind. Well why not just create the parent folder again?
Of course you can have some user rights issues, but that can be solved as well.
Create a unique placeholder file which you exclude from the robocopy command.
One liner is a s follows:
Use the /mov switch instead of /move
I have just performed a test using the
/mov
&/e
switches, and it works perfectly.Noting from the command line options, there is a difference between
/mov
and/move
. The test file moved across to the destination, leaving the directory structure on the source intact."My" solution is to move files and folders inside a temporary folder in the source folder. (do not copy the temporary folder to it self !) And after move this one to the taget folder.
I just detect that the "move" to the temporary folder takes too much time. Here the update :
I got lucky finding the answer. I wanted to move a folder to the top level of a disk. I tried:
It gave an error using the following for destination: H:\" \MOVE \E\.
I guessed that the "\" was escaping the following double quote, and I changed the command to:
It ended up copying the content of "" into the root of the drive.
So the anwser to the question is:
Regards,
Georges
just add \*