up vote 8 down vote favorite
1
share [g+] share [fb]

My wife has several files and folders that somehow ended up having filenames that have caused them to be undeleteable (can't be deleted) by normal means or via the command line. I believe the filenames are too long due to the depth of the folder structures. Does anyone know of a good utility for cleaning up files like this?

link|improve this question
How were these files created? – Nick Mar 25 '11 at 15:44
feedback

7 Answers

From a command prompt:

dir /X

This will list your files/folders in short name format. Then use the short name exactly as written to delete the file:

del LONGF~1.txt
link|improve this answer
I like that one, it's a nice bit of lateral thinking. – Col Sep 23 '09 at 16:03
While I can't guarantee it will work in this case, I've used it several times to delete folders that have invalid characters at the end that make them impossible to delete by normal means. – Will Eddins Sep 23 '09 at 16:03
I just used this technique to delete a file with an invalid filename - it was a file named "},". This tip solved it. Thanks Guard. – Charles Roper Oct 3 '09 at 12:57
This works for files and folders in the current directory, but if you somehow manage to find yourself inside a folder whose path is too long, it will not help. For example, I am currently in a console in a too-long path and cannot even dir or cd ... – Bobson Nov 21 '11 at 2:48
feedback

I progressivley work my way into the path, renaming each successive parent folder to "1" and attempting to delete. You're effectively shortening the path each time and I've never had to work in by more than 4 or 5 directories until I'm finally able to delete the entire directory structure (which may or may not be what you want). You could do this from the last child folder as well and work your way up or down.

link|improve this answer
This was the only thing that worked for me. All the other tricks given here and in other forums such as this didn't work. – Andrew Arnott Dec 26 '10 at 1:23
Glad to help... – joeqwerty Dec 26 '10 at 16:45
feedback

In some programs, including Command Prompt (cmd.exe), you can get around the file length limit by prefixing the full path with \\.\ like this:

\\.\C:\some directory\other directory\a file with long name
link|improve this answer
feedback

Rename the directory of cut/paste the file somewhere else, then delete it. Works here.

Or just from the command prompt, if you don't feel like going through the trouble.

link|improve this answer
feedback

The simplest way I've found is to boot from an ubuntu live CD.

As an alternative you can create a shared folder halfway down the path and then map a network drive to that and do the delete from the mapped folder (even on the same machine)

link|improve this answer
4  
It's funny how often an Ubuntu Live CD will help troubleshooting Windows problems ^^ – Ivo Flipse Sep 23 '09 at 16:07
1  
I've noticed that myself, dodgy network try a live CD, filesystem issue try a live CD, corrupt partition table etc. etc. :-) – Col Sep 23 '09 at 16:12
feedback

Probably not the best way and I am interested to see what others come up with -

I had this once and I tried a few things without any luck. Rather than looking for a good tool, I restarted with the Windows Disk in, went to the recovery console and just deleted it from there. Worked first time and really well!

Also, just did a Google for you and found this - DelinvFile Looks Good but cannot vouch for it.

Edit - Warning, just seen the above is only a trial - Maybe not as good as I first thought!

link|improve this answer
feedback

You could always try Unlocker as it has delete capabilities for 'awkward' files.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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