Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

The MOVE command does not work when to ovewrite a directory. I have also tryed to run cmd with admin rights. I'm posting this question with more info so you can easily test it self.

Make your own folder somewhere and open command window at that location. Then copy and paste this block into cmd-window to create teststructure

MD aaa\test\a
MD aaa\test\b
MD bbb\test\b
MD bbb\test\c
MD ccc\test\a
MD ccc\test\c
ECHO hello > aaa\test\a\a.txt
ECHO hello > aaa\test\b\b.txt
ECHO hello > bbb\test\b\b.txt
ECHO hello > bbb\test\c\c.txt
ECHO hello > ccc\test\a\a.txt
ECHO hello > ccc\test\c\c.txt

Now I want to move and merge all "test" folders in ".\test"
The MOVE command is fine, but in win 7 it fails(Access Denied) when to overwrite existsing "folders". if you now try following block one by one, the first will be ok, but next will fail.

move /Y aaa\test .\
move /Y bbb\test .\
move /Y ccc\test .\

However I have found other solutions which does the the same.

XCOPY aaa\test test\ /E/Y
XCOPY bbb\test test\ /E/Y
XCOPY ccc\test test\ /E/Y
RD aaa\test /Q/S
RD bbb\test /Q/S
RD ccc\test /Q/S

XCOPY and Then Remove Directory

ROBOCOPY aaa\test test\ /E /IS /MOVE

ROBOCOPY with the /Move option

COPY command is totally useless in this case...

I do really need MOVE command to get a batch file with this contetnt to work wich worked in XP.

move /y "%1" c:\mydir\

I tryed robocopy, but then it will move only the contents of the folder. not the folder completly.

robocopy "%1" c:\mydir /E /IS /MOVE

If you wish to help me, then you can do it in two ways..
1) Find a solution to get MOVE to work as in XP
2) Find a way to do the same as what move /y "%1" c:\mydir\ does

A suggestion could be to get the folder name from the path and do something like this

// %1 = "c:\anotherdir\cool"

if %1 is path_to_a_folder then (
   get %foldername of %1
   robocopy "%1" c:\mydir\%foldername /E /IS /MOVE
) else move /y "%1" c:\mydir\

EDIT: Hey this works fine for directoryes, what more can i do so the script also can work with files?

robocopy %1 "C:\Users\azizkar\Desktop\ebben\%~n1" /E /IS /MOVE
share|improve this question

marked as duplicate by mdpc, Kevin Panko, MariusMatutiae, zekk, Scott Jun 14 '15 at 4:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The move command did not work like that in XP. It has always behaved like this (it cannot merge or overwrite directories). – Bobson Sep 24 '11 at 1:35
You have right. I tryed it in XP yesterday and it was the same. Sorry about my mistake. I was sure that this worked earler, but it did'nt. – Aziz Sep 27 '11 at 9:33
up vote 1 down vote accepted

At last.. here is the solution.. Thanks for help guys :)

SET mydir=C:\mydir
IF EXIST "%mydir%\%~n1\" (
  ROBOCOPY %1 "%mydir%\%~n1" /E /IS /MOVE
) ELSE (
  MOVE /Y %1 "%mydir%\"
share|improve this answer

XXCopy would be my recommendation.

A versatile file copy utilitiy.

enter image description here

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .