by Eric Bright
Updated on February 12, 2019
Objective: removing an apparently irremovable file or folder.
Affected OS: Windows 2000, XP, Vista, 7, and newer versions
You have a FOLDER on your desktop with a FILE in it, which you cannot delete.
You’re given this message:
“Cannot read from the source file or disk.”
Possible “solutions” that might not work:
- You tried to find how to delete it; you googled it, read all newsgroups, posts in some professional forums, asked your friends, downloaded
IObit Unlocker (and an article about it), EMCO MoveOnBoot, LockHunter, CopyLock, KillBox, Delete Doctor, Deleting Invalid Data Files [see the end of this page for more information on this program; this program is more than what you may guess], DeleteFXPFiles, and Unlocker (it has an x64 version too and a Win7-x64 works only with the x64 version of Unlocker), installed, and performed what they suggested; and finally frustrated by failure.
- You downloaded Process Explorer and examined every single process running in memory to find a sign of a program that may be using _something_ in that folder. You closed all programs, every resident applications, and all running processes that can be closed. You also closed even some of Windows process and stopped as many services as possible; no sign of any file handle to anything related to that folder… result: negative.
- You have uninstalled many programs that you suspect they may cause the problem;… negative.
- You booted up in Safe Mode, tried to EndTask explorer.exe while doing some hacks in cmd prompt like deleting the folder and…
- You read “How to Delete a Locked Files,” “How to delete a file when…,” and “How to delete locked files on Windows 10” article;… negative.
- You tried to do “Open with…” then created a file with the same name, saved over the existing one… with no luck.
- You have no Spyware, no virus and nothing suspicious at all.
- You did chkdsk c: /f, RegSeeker, NortonDiskDoctor, Regedit (see also this), and lots of command line instructions that you read in forums;… negative (in regedit, you cannot even see any entry with the same name as that stupid file in your Windows registry.) (more about chkdsk.)
- You have tried ShellExtensionsView (or its LiberKey portable version) to disable the suspected PGP context-menu plug-in, which sometimes causes some problems; … negative.
- In the end, before installing a fresh damn Windows, why don’t you try this one:
At a cmd prompt type the following:
[on Windows XP]
C:\Documents and Settings[your log-in name]\Desktop\>RD /S /Q foldername
[on Windows 7]
C:\Users[your log-in name]\Desktop\>RD /S /Q foldername
Another example: assume I have such a bad folder on my desktop; its name is StupidFolder, and there is a file inside it, named BS. with a zero length and no other retrievable properties, or perhaps it has a creation date; assume that my log-in name is eric and we are on a Win 10 system. Now:
- Run -> cmd.exe
- cd c:\Users\eric\Desktop\
- rd /s /q stupidfolder
Be very careful with what you are doing, otherwise, you may lose everything on your desktop. The path of the command must be correct. Please double-check the spelling before pressing the [Enter] button. If you are not sure about what is going to happen or if you don’t know whether the path of the StupidFolder is correct, DO NOT DO WHAT I SAID. If you lose your valuable data, nobody, including me, would be responsible, but you yourself.
A little background about RD command
It goes back to the era of MS-DOS (see also Basic DOS commands on Sophos). At that time, let say DOS 6.3, you could MakeDirectory(s) with this command:
It was also easy to RemoveDirectory(s) with the following command:
However, the directory that you had attempted to remove had to be “empty,” otherwise, you could not remove it. You also “could not delete” a directory with the following command:
because the delete command could work only on “files” not “folders.” Then, when your folder was not empty, you first had to go inside that folder, delete everything, come out of the folder, and finally remove it. Still, if there were “many” folders inside one another residing in the main folder that you wanted to remove, you had faced a nightmare.
Luckily, there was a solution to that: deltree. It was not a native command of command.com (command.com was a kind of the kernel of the operating system). It was an external file that you could obtain from elsewhere and use it for that purpose. Then your computer could automatically go to the deepest directory, delete everything in it by this command:
(without asking permission from the user except once at the start time) and remove every directory that may be there by an rd command, come up by one sub-directory and repeat these steps again up to the first directory.
When Windows came to the scene, things got changed; directories turned to folders, and rd (remove directory) and del (delete or erase) and deltree merged down to one command: delete. Therefore, you became able to delete a directory, read a “folder” now, regardless of if it has any sub-directory(s) or files inside, and there was no difference between a folder and a file for the purpose of deleting anymore; you could delete a folder as well as a file, a task that was two different tasks in MS-DOS time.
Since the emergence of Win 2000, the external command of deltree went inside the RemoveDirectory command as its switch or parameter, named /s. Then we have had this command:
rd /s [drive:]path
that does this:
It “removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree,” its help says.
- RD and RMDIR are identical commands
- You can also use it this way if you don’t like working directly with cmd.exe:
cmd /C RD /S /Q C:\Users\eric\Desktop\StupidFile
but, replace the username and StupidFile with your own stuff. So the general command would be:
cmd /c rd /s /q [drive:]path
- Generally speaking, no file in the destination path must be currently in use, which means if the path is not empty, no program must be using any file(s) from inside of it. That is why we say, ‘close all applications; even go to task manager and close every program that you can (not the windows itself)’
- If you considered the above-mentioned item, it would be much better to even End Process Tree of explorer.exe from your Task Manager; while in Task Manager, go to the tab that is called “Processes, then right-click on explorer.exe, then choose End Process Tree. Doing this, you make sure that at least there is no open file handle from explorer.exe to anything inside the StupidFile. When you finished, you can bring your explorer (and your desktop) back by ‘File -> New Task (Run)… -> explorer (and [Enter], of course!)
Received comments – Adaptations, Hints, and Tricks
I received great comments full of love. I also love you all, my friends. In some of the received e-mails, I got some variations of the rd method that I would be honoured to share with you.
An adaptation by Uhl Albert:
I had tried a bunch of solutions from your page (and elsewhere) but none of them worked. This is what finally did it for me:
1. Log into Windows as another user [must be a user with all administrative privilege]
2. Open Windows Explorer and navigate to: c:\Users\UserName <–user name with the bad files
3. Go to Tools Folder Options and click the View tab. Make sure all settings that hide files are turned off. You want to make sure all files are visible before the next step
4. Move all the files in the Desktop folder to another location (well all except the problem files. If those could be moved you wouldn’t be in this predicament!)
5. Open a command prompt and navigate to the above location
6. Enter this command which deletes the Desktop folder and its contents: RD /S Desktop
7. Create a new Desktop folder
8. Move everything back
9. Log off, then log in again
My complementary notes on the adaptation:
When you are using this method, you should have Administration privilege. Otherwise, you would never be allowed to delete the actual Desktop folder of any user in any circumstance.
The problem of more-than-8-charts-long names: Noticed by Nicolas Huguenin
… the folder I wanted to delete had a very long name (two times wrapped in the CMD) so I wasn’t able to delete it with its long name using the rd command. But using first a dir /x to get the 8-chars name of the folder, I could finally remove it with the rd /s/q.
You may want to add that trick to your otherwise great tutorial, as many of the “young” users might not even know that one day (not so far ago) all names were 8-chars max ;)
My complementary notes on the trick: What does dir /x mean?
Well, it is a wise move. Because there are always some instances of horribly-long file-names with lots of symbols and spaces in them. This would make applying rd impossible for folders with space in their names. This makes applying many other MD-DOS commands impossible too.
- I created a folder on my desktop called ‘Stupid Test’. Note that there is a space between Stupid and Test
- Now I want to remove this folder with rd command. Then I write:
C:...\Desktop>rd Stupid Test
And I receive the following messages (one message, two times):
The system cannot find the file specified.
The system cannot find the file specified.
What is the problem? The ‘Stupid Test’ folder is there. Then why the rd command cannot find it? The problem is that the rd command interpreter, like many other MS-DOS commands, cannot understand the space in the name of a file or a folder. It looks for a folder with the name of ‘Stupid’ and a folder with the name of ‘Test’, but does not look for a folder with the name of ‘Stupid Test’. Then it says, ‘the system cannot find the file specified’ two times, once for each part of the name. This behaviour is ridiculous, isn’t it?! Yes, it is, I believe, and so did guys in Microsoft.
Years ago, names of folders couldn’t be longer than 8 characters, because of some profound restrictions in the available ‘file management’ system, and names also couldn’t bear any space in them. They also used to be started with a letter, not a number. We also couldn’t have some symbols in the name of a file or a folder. It sounds awfully restrictive. Then Microsoft changed everything and removed this absurd limitation in its later operating systems, i.e. in its file management system.
However, for the sake of some backward compatibilities, Microsoft decided not to set MD-DOS commands totally apart. So, This problem is inherited from MS-DOS to its descendants. Today, still some of the MS-DOS commands in Windows family face the same difficulty that their predecessor had faced. They cannot understand longer than 8-charts names, nor can they understand folder names containing any space.
What is the solution?
Microsoft guys have provided us with a tool to tackle such a complication. The solution is using dir /x.
The purpose of using dir /x is to create 8-charts long MS-DOS compatible file and folder names that are placed in the current folder. If the desktop is your current folder in DOS prompt, then it means dir /x gives 8-charts long names of all files and folders in your Desktop. Then we can use their 8-charts equivalents with all spaces eliminated and long names shortened up to 8 characters. For instance, a name like:
would be contracted to: ‘TEST12~1’, or a name like: ‘123456789 123456789 123456789’ would be contracted to :
‘123456~1’. By doing this, we have 8-charts long names without space in them that can be understood by many MD-DOS commands in Windows family, let say in Win XP.
Now, let’s go back to our ‘Stupid Test’. Assume you are in your Desktop (that means your current folder is C:…\Desktop):
- To see what exactly dir /x does, type ‘dir’. You’ll see a list of the names of all files and folders on your desktop, and you’ll see our ‘Stupid Test’ folder there as well
- Now, type: C:\...\Desktop>dir /x. You’ll see, again, a list of the names of all files and folders on your desktop, but all longer-than-8-charts names are also given their 8-charts long equivalents this time. So you’ll see that our ‘Stupid Test’ folder has the 8-charts name of ‘STUPID~1’
- Again, try the rd command, but this time give the contracted name:
(the command is not case-sensitive!)
Gratefully, you can get a software named Delinv File. It is also created to delete non-deletable files and folders that show the same symptoms. The author of this program appears to have the longer-than-8-charts-in-name problem in mind. However, you are advised to be careful when you are using this program, and any other program with the same forceful functions, since you may mistakenly delete a wrong file or folder (your whole Desktop, for example). In many cases, once a higher order change is finalized, it would be almost irreversible (at least for novice computer users).
I got an e-mail from the creator of Delinv File, Jim Lawler, in which he explains how the problem with accidental deletion of stuff is partially dealt with in the latest version of the software. Jim has added still another level of confirmation when a folder is selected to make it even harder for one to accidentally delete things. Though the software recently got commercialized, the good news is that the commercial version still contains perfectly-working functions of the original non-commercial version for free. That is really kind of Jim; thank you Jim!
My special thanks go to Uhl Albert and Nicolas Huguenin for sharing their experiences with you and I. I am also thankful for Jim Lawler’s informative e-mail (he is the programmer of Delinv File). He informed me of the latest changes in his useful software, and he gave me some feedback on this writing too.
(last update – February 12, 2019. Changelog: updated broken links.)
(16th update – July 07, 2018. Changelog: updated broken links, corrected typos, I know. Typos never die. ?)
(15th update – January 30, 2018. Changelog: updated broken links, updated for Windows 10, several formatting and typographical improvements)
(14th update – November 11, 2014. Changelog: corrected typos and mechanical errors)
(13th update – March 11, 2014)
(12th update – June 07, 2012. Changelog: updated the external links; added new links; added new applications; minor error corrections; minor extra clarifications; minor textual adjustments)
(11th update – August 25, 2011)
(10th update – January 02, 2010)
(9th update – March 26, 2009)
(8th update – January 23, 2009)
(7th update – October 22, 2008)
(6th update – August 19, 2008)
(5th update – March 26, 2007)
(4th update – March 07, 2007)
(3rd update – December 21, 2006)
(2nd update – February 20, 2006)
(1st update – November 02, 2005)
125 thoughts on “StupidFile! – Cannot Delete File On Desktop”
Thank you!!! I’ve had a “StupidFolder” for years that I couldn’t delete, but your site helped me rid my life of this annoyance! Thank you!!!
I also had problem like this. It was big headache for me for long time. But then I found http://www.deletelongfile.com, it saved me so much time!
The name I wrote is a little bit of a pun, replacing the 4 letters that made up the file name with my own name, and also to differentiate myself from the other Alexes.
This was very helpful Eric, thank you. That Delinv File thing ended up working for me.
One thing I wanted to know though, since I didn’t see it anywhere on the page, how does this type of thing happen? How do you reproduce or avoid reproducing it?
I liked the way you chose the name!
As for the actual cause of the mischievous bevaviour of the system, I cannot think of anything but a registry glitch. Such a behaviour is a result of a ‘bug’ in the system. If you ask: “What piece of code, exactly, generates such an error?” I must say that I don’t know. But we know two things that qualify us for labeling that behaviour as a bug: (1) it should not happen but it does, and (2) it is hard to prevent it from happening again because we don’t know exactly what goes wrong that causes it. The second part: “… because we don’t know exactly what goes wrong…” should not be the case. If we knew it, we would have prevented it. We don’t know it, so we cannot prevent it.
Here by “we” I shall mean ‘the end users who do not have any access to the source codes of the operating system.’ I am sure that there are many programmers out there who will be able to tell ‘us’ what goes wrong in such cases ‘without having any access to the source codes either’ and with the help of some indirect interpretations, monitoring, and tracings. Unfortunately, I don’t posses that skill. So, I don’t know, and cannot figure it out now. My limited understanding of the phenomenon is that it is caused because of a corruption in registry of the operating system.
In case if I figured that out I will make sure to update the article to reflect that new finding. Thank you for your kind feedback and your attention.
Had a same problem than Derrick
A folder created at a backup disk in FAT32 generated many files with unreadeble characters…
Tried almost every way proposed here, all the DOS commands i got Folder is Not Empty and Syntax Error or File does not exist.
When i tried the DelinvFile you posted above, it gave error Folder Not Empty when tried to delete the folder with the stupidfiles, and file does not exist when i tried to delete de stupidfiles individually.
Suddenly, after performing the DelinvFile i went to the windows explorer, browse for the stupidfolder and bingo… I could finally deleted it…
Thanks 4 your help…
You are welcome. I’m happy that you could finally delete the stubborn folder.
Thanks so much for this, I tried everything to get rid of a stubborn file, this worked perfectly. Keep up the good work! :)
Sweet Jesus I finally got rid of that damn file, THANK YOU! I had to try C:\…\Desktop>dir /x and then delete the file with the ~ name it gave me.
You are welcome! ;)
Hey Eric, thanks for the chkdsk z: /f command, worked like charm on my weird folders created on my external hard drive.
You are welcome. I’m happy to hear that your problem’s resolved now.
you saved me hours of wasted time on this silly problem. Thanks. amazing what lurks out there in old DOSland
Thanks soooo much! You saved my sanity and my computers life! :) There was no way that was staying on the desktop – and this solved it in a matter of minutes (after looking for an answer for days)…
Thank you very much!!
Unlocker Works For Me!!! Thanks Eric!!!
Thanks… solved a lotta headache.
You are welcome! ;)
I had a torrent file on the desktop driving me nuts – my husbands porn, complete with descriptive file name and I couldn’t shift it. I used del and it’s 8 character name and it’s gone! Thanks!
You are welcome! I’m happy that you finally could get rid of that file.
You are very welcome! Happy to hear that the problem’s solved.
Thank you VERY much. CHKDISK c: /f did it.
Hi Alex. Okay. Let us try to narrow down the issue. Please do the followings:
1- Start -> Run -> CHKDSK c: /f
3- Try Unlocker (remove on reboot) again
4- Let me know of the results