Take the 2-minute tour ×
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 any way around this problem?

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

I'm running Win XP, and it's a NTFS drive.

share|improve this question

4 Answers 4

up vote 9 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
1  
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
    
"mydomain.com " as a folder. DOS thought the 8.3 filename was "mydoma~1.com". But it worked. Super thanks! –  Coomie Dec 8 '11 at 6:09

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

Then the DOS name:

dir /x
rd FOLDER~1

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

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

Your Answer

 
discard

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.