Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a folder via PHP, but I made a mistake since I forgot to clear spaces. Now I cannot delete this folder.

I have found a similar issue here - look at the second answer (Quoted below), but I don't know how to rename a folder with 7-Zip.

I had the same problem, in Windows 7 x64, and none of the command-line solutions worked here.

What fixed it for me:
•Rename the folder using 7-Zip
•Delete, either using 7-Zip or Windows Explorer (both work).

Note that deleting the folder in 7-Zip before renaming it was impossible.

I also tried the command line, but it does not work. My folder is named " 1 ".

I downloaded 7-Zip, and Google does not provide the help I need.

share|improve this question
Try my new suggestion in my answer. – BloodPhilia Mar 13 '13 at 15:44
Folder names that start and end with spaces shouldn't be a problem on Win7. I was able to create a folder named " 1 " and then delete without problem using just the mkdir and rmdir commands built into cmd.exe. Is it possible the name contains other characters? E.g., are those double quotes part of the name or is it possible those spaces aren't spaces and displaying as spaces? – Nicole Hamilton Mar 13 '13 at 16:39
I have to agree with Nicole, here must be something else you guys are missing. Leading or trailing spaces are no problem for Windows 7 using mkdir to create a folder called " test " and normal deletion via Explorer afterwards – nixda Dec 27 '14 at 12:45
Great solutiion i had a file named "Invisble, Inc." which was created by Steam and belonged to the game Invisible Inc. Using 7 zip i was able to rename it and after that deleting it. – l1zard Feb 15 at 18:38
up vote 2 down vote accepted

Find the item you want renamed in the main window. Then right click the file/folder in the list and click "rename".

You could also select it by clicking it once and press F2.


Try this from the commandline:

rename "\\?\c:\<PATH HERE>\[ ]1[ ]" "<NEW FILE NAME>"


rename "\\?\c:\<PATH HERE>\ 1 " "<NEW FILE NAME>"

Mind you, the NEW FILE NAME doesn't take the full path, so just use the file's name. PATH HERE is just the path without the file.

share|improve this answer
With the first example : not found - With the second : incorrect syntax - Should I do it from the root ? – Ocelote Mar 13 '13 at 15:49
@Ocelote can you post the commands you used as a comment? – BloodPhilia Mar 13 '13 at 15:50
I used cd to go to images, and from there : \\?\C:\Websites\education-fonctionnelle\images\[ ]1[ ]" "2" => not found. \\?\C:\Websites\education-fonctionnelle\images\ 1 " "2" => incorrect syntax – Ocelote Mar 13 '13 at 15:55
@Ocelote, after the NEW FILE NAME, you should end with a ". I don't see this in your comment, did you use this? so: \\?\C:\Websites\education-fonctionnelle\images\[ ]1[ ]" "2" – BloodPhilia Mar 13 '13 at 15:56
I managed to do it again. For whoever passes by here try the command lines above. I also tried rd "\\?\C:\Websites\education-fonctionnelle\images\[ ]1[ ]" "2" (which is not correct but still, it is part of what I did) THANK YOU !!!!!!! – Ocelote Mar 13 '13 at 16:22

The answer from @Ocelot did not work on Windows Server 2008 R2. What did work was:

Open a command, change to the directory and do a "dir /x". You will see the long and the short name of the directory. You can always rename the short version as it does not contain spaces most of the time. So a ren 3839F~1.4_T whatever should be possible.

share|improve this answer
This is the correct answer with the current versions of the operating system. Smart, using the 8.3 file name support. I wonder why the "\\?\" hardware path was is longer supported, that is also required to support paths with a total length of more than 250-odd characters. – Code Chief Oct 6 '15 at 9:58

Are you using Windows 7? Try to do a chkdsk /f on the affected drive. It should correct illegal filenames (beware: it will move the files to a FOUND.000 folder on the root)

share|improve this answer

I just had the same problem. After using a renaming utility, I discovered that I had four files that had a leading space. I tried renaming it, but Windows coughed and said that the names couldn't be changed.

I decided to add a character (in my case, I just typed "1") in front of the leading space and I could save it (renamed). I then could rename the file by removing the character (again, in my case I just added a "1") and the aforementioned leading space without any problems.

share|improve this answer

I had two files, one with a space at the end, and the other with a period at the end. Windows refused to allow me to rename or delete either. I tried doing it through Python's os module, as well, to no avail. The solution that finally worked for me was to open a command prompt (cmd.exe), cd to the folder, and then run the command:

del *.*

Of course, this means moving everything you want to keep out of the folder first.

EDIT: Sorry, reread the question and realized you are talking about a folder, not a file, so my answer really doesn't help you, but I'm going to leave it here for anyone else who has similar issues.

share|improve this answer

Use the old DOS 8.3 naming method:

If the directory was called "Blah " then you could cd Blah~1 for example. Delete the contents of the folder, then at the root you could rmdir Blah~1

share|improve this answer

I just had a similar problem with folder "Monuments - Discography " created in linux. Windows Vista and Windows 7 couldn't recognize this folder as a valid data and when I tried to rename or remove it I got Info message saying that folder does not exist etc. The solution was to explore a dir with 7zip file manager and rename the folder by removing a white space from the end. Simple. Now I can enjoy the music once again :D

share|improve this answer
The OP said in their question that they do not know how to rename a folder using 7-zip. Can you please explain how to do that? Thanks. – Cfinley May 7 '15 at 18:30

Install winrar. Open it up, navigate to the file location, and you should be able to rename it. (I was having the same problem and this worked for me).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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