3

Edited

I need to move a subfolder to another subfolder. When I use this command:

move e:\rootfolder\sourcefolder c:\rootfolder\destfolder

I get Access is denied.

Notice how the source drive is e: and the destination is c:. I believe the first answerer was right about this being the problem with the cmd.exe. I will give it some time before I mark their answer.

6
  • When I try this on Windows 7, creating both a source and destination folder as per your command, it "just works". Have you checked ownership and permissions on the destfolder?
    – PJC
    Oct 31, 2012 at 14:08
  • I can move the folder via click and drag using Explorer, so I'd have to assume that my permissions are adequate. Oct 31, 2012 at 14:11
  • You can sometimes get permission error if the source folder is in use, including if the folder is opened by a command prompt or by explorer.
    – sgmoore
    Oct 31, 2012 at 14:19
  • I assume permissions based. Please note, scripts are not guaranteed to run with the same permissions as the account you're logged in on.
    – Dave
    Oct 31, 2012 at 14:36
  • Dave Rook - Yes, a subfolder, in fact. I tried moving them to a subfolder of C:, but I am getting the same error. Oct 31, 2012 at 14:39

2 Answers 2

3

Looks like this is the expected behavior (for some odd reason) when trying to move folders between drives.

http://technet.microsoft.com/en-us/library/hh849852.aspx

Move-Item will move files between drives that are supported by the same provider, but it will move directories only within the same drive.

I know that link says it applies to Windows Powershell, but I just tested on my XP machine here at work and see the exact same behavior, so I believe it applies to cmd.exe as well.

0

It's a circuitous method to say the least, but as I encounter this frequently, I came up with a solution that accomplishes the same thing with no major speed difference. Requires that you have 7z.exe (can be downloaded here) installed, and added to your path. 7z is a fast command line archiver, thus this could also be done with tar.exe,gzip.exe, etc.

I do something like the following:

7z a x:\destinationfolder\tmp.7z c:\directoryyouwanttomove && ^
7z x x:\destinationfolder\tmp.7z

I recognize that this is way old, and I'm not specifically answering the op's question, but I had a really hard time finding this documented anywhere, and I perhaps could save someone some pain.

You must log in to answer this question.

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