Hi,

I’m trying to use robocopy to move files and folders from one location to another but it’s not working the way I want it to, can someone please help? I’m trying to use the /Move switch to move and delete all the files from the source after moving. The switch is working but it also delete the main source directory as well. This is what I have:

robocopy.exe “c:\source\transfer” “e:\destin\New” /S /Move

This works but then it also delete my “transfer” folder which I don’t want. I just want to everything inside the transfer folder and then delete everything inside the transfer folder only. What am I missing?

Thanks!

5 Spice ups

possibly a “e:\source\transfer*” will fix this?

Run your command with copy in stead of move and then run a command to delete everything in that folder after it has run? I think that would be a good way to do it, don’t have the ability to check all the Robocopy commands at the moment.

http://serverfault.com/questions/167723/robocopy-how-to-move-the-content-of-a-directory-but-keep-the-directory

Try this

Good information for robocopy: http://community.spiceworks.com/topic/209362-robocopy-e-folder-name-e-new-folder-e-sec-move-r-0-w-0

Here’s Microsoft technet link on Robocopy and switches

See below about the move switch

/mov
Moves files, and deletes them from the source after they are copied.
/move
Moves files and directories, and deletes them from the source after they are copied.

3 Spice ups
robocopy.exe "c:\source\transfer" "e:\destin\New" /S /Move
mkdir "c:\source\transfer"

…perhaps?

2 Spice ups

Here’s a couple of links that use as reference when using robocopy

Looking over the different switches try using /mov instead of /move

/MOV : MOVe files (delete from source after copying).
/MOVE : Move files and dirs (delete from source after copying).

2 Spice ups

Jeremy and Krizz have the best answer to this. I guess I can’t accomplish this with just one line of command but will have to include a second line in my batch file to either recreate the folder or delete all files and folder after they have been copied. Thank you guys.

robocopy.exe "c:\source\transfer" "e:\destin\New" *.* /S /Move

the . should tell it just everything inside the folder.

Benjamin - that doesn’t work, it still deletes the source folder.

Maybe use the “/Mov” switch instead of “/Move”

/MOV :: MOVe files (delete from source after copying).
/MOVE :: MOVE files AND dirs (delete from source after copying).

***Edit - Sorry did not see michaelp236’s response.

2 Spice ups

/Mov does not work either as it leaves a bunch of empty directories behind which I will then have to use another command line to delete everything inside the source folder.

I use robocopy a lot as well and I would like to help but I cannot offer much beyond what as already been said. Maybe if I had a better understand of what your working with I could be more helpful. What is the folder structure like? Why do you need to keep the source folder? Things like that.

If I wasn’t being clear from the previous response then here it is again. Both Jeremy and Krizz have answered my question.

Please, mark BA/HP then. Until then, people will try to provide solutions to unsolved problem.

Em8, you will need /e instead of /s to remove empty folders with RoboCopy (assuming this is still relevant).

This will do it: robocopy c:\source\transfer e:\destin\new /mov /s

Simply add the /EF (excluding the folder) to the cmd as below

robocopy.exe “c:\source\transfer” “e:\destin\New” /S /Move /EF “c:\source\transfer”

Hope this Helps

1 Spice up