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

I have a bunch of folders on my hardrive that have trailing spaces in them (I have no idea how they got there). I need to rename and/or delete them, but Windows won't allow me to do this. Is there a way around this problem?

I've tried to delete it via the commandline, but that did not work.

I'm running Windows XP, and it's an NTFS drive.

share|improve this question

5 Answers 5

up vote 14 down vote accepted

First try some quoting:

rd "my folder   "

Then UNC paths:

rd "\\.\C:\temp\my folder   "

Then try adding a trailing [back]slash:

rd "my folder   \"
rd "\\.\C:\temp\my folder   \"

Then 8.3 names (if they are enabled on your system):

rd myfold~1

Then a Linux LiveCD:

rmdir "/media/blahblah/temp/my folder   "
share|improve this answer
Deleting using the 8.3 names worked. Thanks –  SuperFurryToad Oct 11 '10 at 15:18
Good ol DOS legacy. –  surfasb Apr 2 '11 at 15:41
" " as a folder. DOS thought the 8.3 filename was "". But it worked. Super thanks! –  Coomie Dec 8 '11 at 6:09
+1 for suggesting also The Linux solution –  Sekhemty Dec 27 '14 at 13:01

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 Explorer (both work)

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

share|improve this answer
7-Zip worked for be on a 2008R2 trailing folder that I could not delete. –  user135634 May 22 '12 at 17:34
Thanks this was the only method that worked for me on a folder mounted from a remote file server –  Anigel Apr 2 at 10:23
wow, that really worked surprisingly well for me - thanks for the less traditional suggestion? –  matt lohkamp Aug 10 at 4:41

Then the DOS name:

dir /x

Then the (UNC?) name which I'm not sure how to find or what exactly it looks like:

rd \Device\HarddiskVolume1\temp\folder
rd \\?\Device\HarddiskVolume1\temp\folder
share|improve this answer
System-local UNC paths start with \\.` for devices and \\?` for files (official doc); using `\\?\C:` is often enough. –  grawity Oct 12 '10 at 18:21

windows 7

I was having issues getting rid of a folder. "C:\Users\Rob\Desktop\Music\ A k o n "

This is what finally worked for me: I opened up the cmd prompt in the Music folder (shift right click, open command window here)

then typed in the following command

rd " A k o n \"

notice the back slash.

beginning spaces and trailing spaces really mess crap up. I spent at least 2 hours searching for a solution.

Thank you grawity for posting the solution.

share|improve this answer

Boot with a live CD of Ubuntu, and you will be able to delete anything you want.

To boot with the CD you should change the boot order in your BIOS settings.

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.