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?
3 Answers
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.
-
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.– JW0914Commented 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.– LPChipCommented 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.– noplaceCommented Mar 15, 2021 at 8:14
There is a bug in Windows 10 - you have to use absolute path.
rmdir /S /Q "%cd%\folder"
On MS Windows you can delete such a problematic folder using 7-Zip file archiver/manager - right click the folder and choose "Delete".
del "\\?\C:\test\1"
for example.