Summary: Sometimes a file cannot be deleted because it has invalid characters in its filename. There are techniques and tools to force the delete anyway.
Why can't I delete this file?
It's a fact that you can create files in Windows that are almost impossible to delete using normal methods. Typically it's the result of a hidden character in the filename - a character that for various reasons can't be seen and is difficult if not impossible to type. And yet if you don't specify the correct filename including that odd character you can't delete the file.
I can hear you asking "great, how did that character get there and more importantly how can I delete the file?"
The answer to the first part is speculation but I was recently pointed at a tool that will help with the second.
•
The biggest issue with invalid names is that not all programs filter out invalid characters from filenames before they pass them on to the system. For example, let's say you happened to accidentally hit the spacebar after the filename when you went to save a file. If the application you're using is not smart enough to strip trailing spaces then it may well create the file with a trailing space. You may think and see "FOO.DOC", but Windows sees "FOO.DOC ". A subtle, but important difference.
What's worse is when you attempt to rename the file or delete the file using a utility that then "does the right thing", it strips trailing spaces before it attempts to operate on the file. You type in or select "FOO.DOC " with a space and the utility takes it as "FOO.DOC" without a space, tries to delete it, and fails because that's not the name of the file!
There are actually several scenarios that can result in files that seem almost impossible to delete. Fortunately they are rare but they do happen.
What to do?
If your file system is FAT or FAT32 or most instances of NTFS you can use the old DOS "shortname". In the days before Windows filenames under MS-DOS could only be 11 characters long. For compatibility with old programs that relied on the 11 character limitation Windows creates a unique "shortname" for every long file name. For example, if your file is named "thisisalongfilename.isntit" a DIR /X in a command shell may show the shortname as "THISIS~1.ISN". It refers to the same file so you can delete using the shortname.
In some cases using the command shell or using shortnames isn't an option. That's a situation I found myself in some time ago. My disks are formatted with NTFS, and I've explicitly turned off "shortnames" for a little bit more speed. I had no way to delete the file I'd somehow created.
I was recently pointed at delinvfile, short for Delete Invalid File, from Assistance & Resources for Computing, Inc. It's a free Windows program that uses standard controls for drives, folders, and files to navigate to the folder and to select the file to be deleted. Push a button and it's gone.
It just got added to my little arsenal of handy tools I carry with me wherever I go.
Article C1907 - March 15, 2004
In my previous post I forgot about file names and folder names with imbedded blanks that need to be enclosed in double-quotes. Replace steps 22 and 23 with the following:
22) To delete a file type in the characters del “ (the letters del followed by a space and a double quote) or to remove a directory type in the characters rd “ (the letters rd followed by a space and a double-quote)
23) Right-click and select Paste and then type the character “ (double-quote) the fully constructed commands look like - del “file name.ext” OR rd “folder name”
Sorry for the over-sight. I think I could use a good a QA person.
Tom
Posted by: Tom at October 4, 2008 10:47 PMRemoving a Windows file is easy, once you figure out what the file is and where it is located. I use this procedure all the time for my wife, who is unwilling to learn a different operating system.
Posted by: Khentiamentiu at October 14, 2008 12:35 PM1. Boot the system from a CD with a live Linux distribution such as Knoppix, Fedora or Ubuntu.
2. Mount the Windows filesystem in Linux, which has no problem reading and writing Windows filesystems.
3. Delete the file with the command "rm ".
Of course, it's not quite that simple, and you need to know that removing the file won't corrupt Windwos so that it won't run, but once you learn a little Linux, it's easier than all the crap you have to go through trying one program after another in Windows. Or you can avoid these problems entirely by using Linux, which these days comes with extensive driver support, easy installation, and an OS more stable and faster than Windows. Oh, and it's free for download, of course. Some very good distributions are Knoppix, Fedora 9, Ubuntu 8.04 and OpenSuse 11.0.
oh God,, there are 100 comments for this Post. I do not think my comment would matter much,, haha,, But wow thanks for solving my problem..And I must say I discovered a new tool .. wow it works great,,
Posted by: Bikesh at December 16, 2008 9:23 AMRead all the comments (on this and other websites) and can't find mention of this solution. Reboot in Safe mode - use Explorer to go to the file, select and delete. This has always worked for me!
Posted by: Geoff at February 4, 2009 9:00 PMHHOOOORRAAAY!!
Unlocker WORKED!. After weeks and weeks of struggle - and I am not a newbie when it comes to Windoze crap. MOveOnBoot did NOT work, unlocker did! I'm sending him a donation!
Steve
Posted by: Steve Crye at February 26, 2009 9:09 PMcant find it in my add and remove to delete it out please help me delete this from my sytem
Posted by: rachel searles at March 4, 2009 5:56 AMWhen I go to 'folderoptions'...oin school or home computer, I find out I cant change some files function its like it cant be highlighted what makes some commands unable to be highlighted?
Posted by: adex at July 7, 2009 3:12 PMMy problem was that with my file buried about 15 folders deep the combination of these folders and the file name they combined exceeded the max file length. I just had to rename the folders to something short until I got under the max length and then I could erase that file.
Posted by: Ron Richardson at November 9, 2009 4:21 PMUnlocker worked!! :D
Posted by: Haikal at November 10, 2009 4:24 AMI have figured out that by corrupting the file it will delete. I corrupted the file by opening it in Notepad and then deleting some of the characters. I may not work with all files but it worked for me on a video file.
Posted by: Brian at November 11, 2009 10:40 PM