I have a problem with delete, I would like to delete some folder which contains a number of files, and I am getting an error like:

Cannot delete Folder: The file name you specified is not valid or too long. Specify a different file name.

How on earth can I delete this? How to force to delete it?

  • this is not Server Fault related. – cd1 Jul 3 '09 at 15:21

See http://www.ratsauce.co.uk/notablog/LongFilenames.asp


PS for a folder use:

rd /S \\?\C:\VeryLongFolderName


Try using a wildcard "*" after the first few characters of the name. Make sure you have enough differentiation so as not to delete what you don't want to.


You can do a dir /x to get the short file name, and then delete that.
e.g. C:\AReallyLongFolderName can also be accessed or deleted using C:\AREALL~1


If it's on a network you can map a drive to the parent folder and delete it that way. You may also be able to subst a non-networked drive.

  • And excellent suggestion that worked well for me given the file was nestled in a sophisticated and deep file sturcture. – Hanshan Dec 13 '12 at 5:26

try to rename file or folder with smaller name or map folder as root then delete

  • The question says windows there is no root on windows. – Unkwntech Jul 3 '09 at 15:24
  • but if you share folder at one computer at another you can map, like root this folder. it is decrease full path length. – Alexander Pavluchenko Jul 3 '09 at 15:37
  • "root" in this case is the top directory of a drive. If you use SUBST you can create a drive letter that points to any directory you choose. – Brad Bruce Jul 3 '09 at 23:12

protected by sysadmin1138 Mar 13 '12 at 16:09

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.