Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
this is not Server Fault related. –  CD1 Jul 3 '09 at 15:21

5 Answers 5

up vote 8 down vote accepted

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

JR

PS for a folder use:

rd /S \\?\C:\VeryLongFolderName

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
    
And excellent suggestion that worked well for me given the file was nestled in a sophisticated and deep file sturcture. –  nulliusinverba Dec 13 '12 at 5:26

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

share|improve this answer
    
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 answers, posting an answer now requires 10 reputation on this site.

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.