Access denied, cmd move windows 7
I can't use this command in win 7 when want to move a directory if the destination exists. It says Access denied. Why hapens this? It worked in XP.
move /y "%1" c:\mydir\I can use robocopy, but then it will move only the contents of the folder. not the folder completly.
robocopy "%1" c:\mydir /E /IS /MOVEHow can I solve this problem?
54 Answers
Try:
IF EXIST "c:\mydir" ( robocopy "%1" c:\mydir /E /IS /MOVE ) ELSE ( move /y "%1" c:\mydir )This will check if the folder exists and move contents if the folder exists and if the folder doesn't exits then it will move your folder. If you still get access denied then you probably need to get admin privileges.
1At 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%\"
) If you are getting ACCESS DENIED error messages when attempting to move a folder, either
- You do not have correct permissions to move the folder
- You do not have the correct permissions to move one or more of the files in the folder
- One or more files are being accessed by the system/an application
- One or more of the files are protected from deletion.
Check for all of these possibilities.
5I'm lame and don't understand exactly what the answers here are doing under the hood so I came up with this copy/paste doozy
SET src=C:\dev
SET dest=D:\dev
IF EXIST %dest% (ROBOCOPY %src% %dest% /E /IS /MOVE) ELSE (MOVE /Y %src% %dest%)