The Short Version:
- Open a command-prompt window (click the “Start” button then type “cmd”)
- Navigate to the folder that contains the offending folder (type “cd temp\foldername\whatever”)
- Rename the file or folder using the Win95/DOS long-file name; let’s pretend it’s called “invalidfilename ” (ren invali~1 goodname)
- Delete the folder (rd goodname)
The RIVETING Full Story:
One of my clients recently sent me a ZIP file with a bunch of songs he wanted to put on his website. When I extracted it, it created a folder that couldn’t be read or deleted.
(See, the Windows file system doesn’t allow question marks, slashes, quotes or spaces-at-the-end-of-folder-names whereas other operating systems do.)
In order to correct this issue, I called upon my brain to remember a few things from the Windows 95 days.
If you were a nerd back then, you might recall being super-excited that Windows finally began allowing long file names. What a marvel! What progress!
You might also recall that when you went into DOS, all your lovely file names — such as “omg this is a long file name” or “this is really amazing” — were butchered into “omgthi~1” and “thisis~1”
It made browsing and file-copying a serious hassle. 17 years later, I STILL have files on my drive with these pooched names…
Anyway, in order to delete a folder with an invalid name, you’ll need to do a little old-school hacking.
- Open a command-prompt window (click the “Start” button then type “cmd”)
- Navigate to the folder that contains the offending folder (type “cd temp\foldername\whatever”)
- Rename the file or folder using the Win95/DOS long-file name; let’s pretend it’s called “invalidfilename ” (ren invali~1 goodname)
- Delete the folder (rd goodname)
HOORAY!
Hehehehee 😀
Nice
Thanks 😉
Well, Long path tool can help on this situation. Thanks
It can be deleted in linux OS,if you have access to.
LongPathTool is payware, unfortunately. Not paying for something I only need once every 2 years.
Great Help!!! Thank you!! Always wonder how Mr. Softy survives and thrives peddling such damaged goods…
If you need to delete files with invalid file names, all you need to do is:
1. Open the Command prompt.
2. Type this command: chkdsk drive: /f /x
e.g. c:chkdsk e: /f /x
It will delete the files with invalid file names…
I always get a little nervous whenever I bring out the auto-fixing, non-confirming chkdsk… sometimes it gets a little delete-happy. But yes, it would work. 🙂
Old school still works! Nice job
You Are A Life Saver
You Are A Hero
I Love YOU!
A really good solution. The probelm was a filename such as ‘afilename.*pg’
This won’t work for me. I keep on getting “the system cannot find the path specified”. Is there some option I need to enable first in order for this to work?
how do i navigate to the folder (2nd step)
Thanks for the feedback, I’ve updated my article accordingly. 🙂
You’ll need to type “cd tempfoldernamewhatever”
Experience from the old DOS days will definitely help, if you have it. 🙂
Hi Xdude,
With your solution it helps to know the DOS (8.3) name of the offending folder with:
<<>>
And you save yourself the renaming step at the same time, in short:
——————————-
Here’s how:
1- Open a command-prompt window (click the “Start” button then type “cmd”)
2- Navigate to the folder that contains the offending folder (type “cd tempfoldernamewhatever”)
3- Type “dir /x” to locate the DOS 8.3 short file name of the folder you want to poof; let’s pretend it’s called “Invalid Folder Version 7.0.1880 (x64)” and dir /x shows its short name to be “invali~1.188”
4- Delete the folder (rd invali~1.188)
—————————
I had this exact problem and a google search brought me to your place, problem was neither chkdsk nor your initial solution helped cause I was unable to ascertain what 8.3 filename the damn folder got, remembered from some time ago to look for the “dir” switch to show 8.3 filenames with a “help dir” and the rest is History. 🙂
This way, no matter what, you’ll be able to delete it (Windows 7 64bits).
Take care