Folder name with a trailing space character

I download a computer program that had a bug: Its installer created a folder named “Bin “; i.e. “B”, “i”, “n”, plus a space character at the end. Its uninstaller cannot delete it.

Standard Windows file system parser removes leading and trailing space characters even if they are included in quotation marks like I wrote above. Make no mistake, this behavior is a godsend in most cases.

Fixing it with Command Prompt

Everyone can just search the Internet and download a third-party utility to fix this problem, but power users and professionals know the value of knowing how to do it with Windows itself. After all, when it rains, it pours! It is possible that the day one encounters this problem is the day that he or she does not have access to the Internet to download a fixing utility.

So, you might be thrilled to known that del, rd and ren commands in Command Prompt support native Windows NT API to access files and folders. (Windows PowerShell apparently does not.)

Simply, enter the full file path and prefix \\?\ to its full path; e.g. instead of the following:

rd "C:\Program Files\Troublesome Software\Bin "

… try:

rd "\\?\C:\Program Files\Troublesome Software\Bin "

Of course, typing full path can be frustrating. You can use %CD% instead of the full path. For example:

cd "C:\Program Files\Troublesome Software"
rd "\\?\%CD%\Bin "

For a file called “Bin.txt “, you can try:

del "\\?\%CD%\Bin.txt "

Please be aware that on my test machine, Windows Shell did not properly reflect the changes until I forced a refresh. For example, I tried renaming a file called “placeholder ” to “placeholder”, Windows Explorer added  a second “placeholder” to the folder and “placeholder ” was only removed when I issued a refresh command. Possibly, it has to do with something in my system, but nevertheless, please bear this in mind.

I was not successful in renaming folders with native syntax; only files.

Fixing it with a third-party app

I said earlier that everyone can just download a utility to fix this problem. But as it turns out, it is not exactly easy. I downloaded and tried eight free file managers but only one succeeded in fixing the problem. Here is a list of what I tried:

Name Result
muCommander 0.9 Failed
Midnight Commander 4.8.11 Failed
DOS Navigator 1.51 Disqualified
Double Commander 0.5 Failed
Far 3.0.3900 Succeeded
Nomad.NET Failed
Explorer++ 1.3.5 Failed
Free Commander XE 2014 650 Failed

Perhaps if I had infinite time, I’d have broadened my search into other genres of utilities. Alas.

Who is to blame?

Great minds discuss ideas. Average minds discuss events. Small minds discuss people. The most primitive of minds blame Microsoft for everything. Good developers test their installers and catch such bugs before hitting release to manufacturing. Need I say more?


Posted on 10 June 2014, in Software Development and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: