"Access denied" when renaming folder from command line

spacexion

Reputable
Sep 18, 2014
4
0
4,510
Hi all.

I'm dealing with a strange problem.
I have to order and clean a quite complex folder structure, and I'm managing that with some batches to rename the folders from command line.

The main structure is something like that:

Code:
E:\MAIN\NAMES_x\UNIT_n
Sometimes, there are subfolders into the "UNIT" folders, such as:

Code:
E:\MAIN\NAMES_10\UNIT_1\LOCATION

My need is to rename the "UNIT" part of these folders. I do not have any problems when I rename a folder which do not have subfolders, but otherwise I get an "Access denied" error each time I try to rename a folder containing subfolders.

For example:
Let's take 2 folders:

Code:
E:\MAIN\NAMES_10\WORKUNIT\ 
E:\MAIN\NAMES_24\RESTUNIT\CHICAGO

Code:
rename E:\MAIN\NAMES_10\WORKUNIT    UNIT_1             >>>>     OK
rename E:\MAIN\NAMES_24\RESTUNIT    UNIT_2             >>>>     ACCESS DENIED

I first thought that some file in the "LOCATION" folders was preventing the system from renaming it, so I also tried to empty some of them (including from system and hidden files): the rename command still fails with "access denied"
No processes are working on these folders.

And the most strange fact: if I move or copy these folders to another location (say C:\users\spacexion\desktop\NAMES_10\RESTUNIT\CHICAGO) I can rename RESTUNIT to UNIT_2 from command line with no troubles!

I suspected some inherited rights issue, but I compared them on many folders and all seems correct with NT rights. Thus, if it was an issue right, I suppose that I couldn't rename the "UNIT" level folder too.
Furthermore, I also can rename these "locked" folders from Windows Explorer, so I really don't understand what's going on....

Any idea?

Thanks!

 

spacexion

Reputable
Sep 18, 2014
4
0
4,510
Thanks for the reply.

Yes, I also opened cmd as admin.

I already considered the "move, rename, move back" solution, but I would rather prefer to avoid it: 75 000 files, 5 500 directories, and near to 2TB of data. If something should go wrong in the process, I would end up with a total mess....