2

I'm trying to delete a folder which was probably created by decompressing an archive file which lead to somehow exceed the maximum path length limitation. I already checked with chkdsk the file system and there are zero bad sectors. The security tab in folder properties returns an error. I've tried all popular suggested solutions to delete the folder both from the UI and command prompt and all fail with the same "The system cannot find the file specified" error. Any other solution?

7
  • Did you try to delete the containing folder? I mean choose a folder up in the tree with a path shorter than the maximum length and remove that one using the command prompt.
    – FluidCode
    Commented Mar 13, 2021 at 11:54
  • have you tried from the command line using the format: del "\\?\C:\test\1" for example. Commented Mar 13, 2021 at 12:01
  • 1
    Does this answer your question? How to delete a file with a path too long to be deleted (do note, you can easily use my answer in this question to delete folders too.)
    – LPChip
    Commented Mar 13, 2021 at 12:23
  • Tried everything I could think of and everything I found as a suggested solution. I tried renaming folder and parent folders. I moved it to shorten as much as possible the full path but the folder itself cannot be renamed or deleted in any way. I tried taking ownership of the folder and tried changing ACLs for it. Nothing, every operation fails with the same “The system cannot find the file specified” notification.
    – noplace
    Commented Mar 13, 2021 at 12:50
  • @HelpingHand no. As said I was able to shorten the full path to a single parent folder but anything else fails including deletion attempts from cmd or UI.
    – noplace
    Commented Mar 13, 2021 at 12:52

3 Answers 3

2

I finally succeeded in deleting the folder. I found on a forum someone who was facing the same error and he suggested using a bash shell and running the rm -rf command. I have git for windows installed which is also installing a bash shell. I ran rm -rf <foldername> from that shell and it worked. Pay attention to this command as it seems really powerful and it probably bypasses some checks that other commands such as rd or del are enforcing.

3
  • The reason Linux's rm command works whereas other commands outside of PowerShell do not, is because Linux doesn't have a 260 character limit for file paths.
    – JW0914
    Commented Mar 13, 2021 at 14:08
  • Seeing what you did, it seems like somehow your MBR got corrupted, leaving you with a ghost folder. It shows up in explorer, but windows can't delete it. CMD's rd -s may have been able to delete it in this case too.
    – LPChip
    Commented Mar 13, 2021 at 19:58
  • I agree @LPChip. Folder creation succeeded partially probably due to a max path length violation and while I could see the folder in windows explorer I could not in any way act on it. rm -rf somehow bypasses some of the checks the other windows tools enforce and thus was able to brutally delete it.
    – noplace
    Commented Mar 15, 2021 at 8:14
1

There is a bug in Windows 10 - you have to use absolute path.

rmdir /S /Q "%cd%\folder"
0

On MS Windows you can delete such a problematic folder using 7-Zip file archiver/manager - right click the folder and choose "Delete".

You must log in to answer this question.

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