You have a FOLDER on your desktop with a FILE in it, which you cannot delete, right?
You’re given this message:
Cannot read from the source file or disk.
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 file when…” 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.
In the end, before installing a fresh damn Windows, why don’t you try this one:
at a cmd prompt:
RD /S /Q [drive:] path
example:
C:\Documents and Settings\[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 INSTR. with a zero length and no other retrievable properties, or perhaps it has a creation date. And my windows log-in name is dlb, ok! Now:
* Run -> cmd.exe
* cd c:\Documents and settings\dlb\Desktop\
* rd /s /q stupidfolder
A little background about RD command
It goes back to the era of MS DOS. At that time, let say DOS 6.3, you could MakeDirectory(s) with this command:
c:\> md my-letters
It was also easy to RemoveDirectory(s) with the following command:
c:\> rd my-letters
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:
c:\> del my-letters
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 for 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:
[drive:]\path>del *.*
(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.
Since the Win 2000 emergence, 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:
deltree [drive:]path
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.
Notice:
* RD and RMDIR are identical comands.
* You can also use it this way if you don’t like working directly with cmd.exe:
Start, Run…
cmd /C RD /S /Q “C:\Documents and Settings\username\Desktop\StupidFile
but, replace the username and StupidFile with your own cases. 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, and use the task manager ‘File -> New Task (Run)…’ etc, etc. 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 am receiving great comments full of love. I also love you all, my friends. In some of received e-mails, I got some variations of the rd method that I would be honoured to share with you.
An adaption 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: \Documents and Settings\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 as the original user
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 circumstances.
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 between them. This would make applying rd impossible for folders with space in their names. This makes applying many other MD-DOS command impossible too.
Example:
1. I created a folder on my desktop called ‘Stupid Test‘. Note that there is a space between Stupid and Test
2. 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 ‘Folder’, 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 agon, names of folders couldn’t be longer than 8 character, 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 folder. It sounds awfully restrictive. Then Microsoft changed everything, and eliminated 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 figuratively 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 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:
‘Test 123456789‘
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 Widows 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):
C:\…\Desktop>
1. 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
2. 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‘
3. Again, try the rd command, but this time give the contracted name:
C:\…\Desktop>rd stupid~1