stupid windows tricks: c:\stuck\ and c:\stuck_\ and c:\stuck__\

I have never understood that for years, you have been able to create a folder with a space at the end of its name in a script. But try, just try, to delete that folder.  You can’t delete it in Windows File Explorer.  In fact, the only way to fix that I have found, is hope its a really long folder name, drop to a command prompt, and delete it with “Del folder~1”.

Well, the documentation for Windows Explorer specifically states that it may not support all the naming conventions of the underlying file systems.  Of course, it would be entirely reasonable to expect it to fully support the naming conventions of any Microsoft file system, but MS seems to operate under an unusual definition of “reasonable”.

You don’t need a script to create such folders, just the command prompt. This will work just fine: mkdir ".\Space \". Even better, dir /X may fail to reveal this as a long filename (by definition, any filename containing a space is a long filename even if it’s eight or fewer characters in length), in which case there’s no way to use dir to make it obvious there’s an abomination in the list of folders.

Note that mkdir "Space " won’t give you the trailing space in the folder name.  You need to use the quotation marks and the slashes.  Similarly,rmdir "Space " fails to remove the directory, but you can remove it with rmdir ".\Space \".

File this under “Stupid cmd.exe tricks”.  Its a fun way to use 3 lines of script to really annoy off your IT co-workers.

Heh, create three sibling directories named “stuck” where they have one, two, and three trailing spaces – then sit back and watch the consternation. It will look like there are three folders with identical names under the same folder (impossible!), and none of them can be deleted with Explorer.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

w

Connecting to %s