14

I named a folder " ", the symbol for a space.

In Linux you can create folders with just a space. Now that I've switched over to Windows, I can't move the folder that has the folder named " " in it. Nor can I move anything in the folder itself, or rename the folder.

I have tried Unlocker 1.9.2, and it didn't work either. It asked me to perform the operation at reboot, I agreed and it didn't do anything.

How can I rename the folder named " " from within Windows?

Thor
  • 3,970

6 Answers6

17

It's not in fact true that this is impossible on Windows. It is possible to fix this with the SFUA Utilities on the Subsystem for UNIX-Based Applications on Windows 7 (Ultimate edition). I just did so:

JdeBP ~/Desktop %mkdir ' '
JdeBP ~/Desktop %ls -ldQ ' '
drwxr-xr-x  1 JdeBP  None  0 Dec 30 16:14 " "
JdeBP ~/Desktop %mv ' ' space
JdeBP ~/Desktop %rmdir space
JdeBP ~/Desktop %

Instead of using rmdir I could have just deleted the space folder from the desktop using Windows Explorer; or done anything else, including accessing its contents (had it had any).

The problem is not Windows NT itself. It's the Win32 subsystem rules for filenames. The POSIX subsysem doesn't impose the same rules.

JdeBP
  • 27,013
8

You could try:
Rename the folder using 7-Zip


Tested on Win7 x64 with 7-Zip portable version

Steps to Reproduce:

  1. Create folder (F7) with default name: "New Folder"

  2. Rename "New Folder" to " "

  3. Rename " " back to "New Folder"


This answer is similar to this one which solve "How to delete a folder containing trailing spaces": https://superuser.com/a/366583/163596

Ivan Chau
  • 1,533
6

The best bet for you to use a live cd of Linux and then rename the folder and then use it windows. AFAIK and others have stated here there is no way to do this using Windows. If I could find a way I would edit my post.

avirk
  • 15,777
  • 3
    Nitpick mode: "There is no way to do this using Windows". No. There is no way to do this using the regular windows API. A windows program which uses its own interface to the filesystem rather than the win32 API can still do this. – Hennes Dec 30 '13 at 16:45
  • Shades of Norton Utilities from Dos days, edit the filesystem on disk by hand. Is it a FAT filesystem (presumably not EXT2-4) ? You should just be able to overstrike it on the disk with a suitable editor. – mckenzm Jan 19 '16 at 01:43
2

As noted, the problem is the Windows user interfaces, not the Windows filesystem.

If you can write in almost any programming language, and that language has a library function which will let you manipulate the filesystem, you should be able to quickly write a minimal program that will let you rename this beast.

Or, as others have noted, you can try using the wildcard approach. ? is a single-character wildcard; if you don't have any other files or directories with one-character names you could try "ren ? foo" and see whether that's enough to sneak past the special-case checks for the space character.

keshlam
  • 143
  • How does this work with other reserved or special characters such as < (less than)

    (greater than)

    : (colon) " (double quote) / (forward slash) \ (backslash) | (vertical bar or pipe) ? (question mark)

    • (asterisk)?
    – Motivated Jan 06 '16 at 05:10
  • There are ways of escaping almost any printing character, in almost any string entry scheme. (Sometimes nonprinting ones too.) Read the fine manual... Or, as I said, wildcard-match them. – keshlam Jan 06 '16 at 06:31
  • This assumes that you have the means of escaping any character since the challenge i have come across is with third-party applications. For examples particular backup or synchronization apps especially if you are transmitting files from one filesystem to another. How do you address these? – Motivated Jan 06 '16 at 08:08
  • If an application can't handle a legal filename, that's an issue with that particular application. Contact the user community, the authors and/or the vendors, and ask them whether this is a bug that they're fixing (and if there's a workaround), a design decision (in which case you rename the file or use another app, your choice), or if you just didn't understand how to do it in this app. Same as with anything else you're having trouble with. Same as was done in this very question. The OS is doing the right thing. – keshlam Jan 06 '16 at 13:25
  • What do you mean that the OS is doing the right thing? – Motivated Jan 06 '16 at 22:43
2

I am running XP so unsure of the specific nuances of Windows 7, but using Cygwin I was able to create a folder named " " containing a few random files, then using the mv command rename the folder and keep its contents.

cd the/path/of/the/parent/folder

mv " " newfoldername

Lizard
  • 21
0

This is definitely untested, but out of curiosity it may be a solution:

  1. Move any other folders that are in the parent folder of your " " folder

  2. Fire up PowerShell, and navigate to the parent folder.

  3. Run Remove-Item .\*

Thor
  • 3,970
  • From the OP: "I can't move anything in the folder." – Hennes Dec 30 '13 at 15:50
  • @Hennes I took that as a "I can't move anything in the folder that is named a space", not as "I can't move anything in the parent folder". – Thor Dec 30 '13 at 15:50
  • I could be wrong. Waiting for the OP to add more information on testing things (and really curious how to handle this kind of thing). – Hennes Dec 30 '13 at 15:51
  • @Hennes We'll just have to wait and see! – Thor Dec 30 '13 at 15:54
  • I cant move the parent folder or any of the children folders.

    EDIT: I want to keep the folders inside, but i can live with deleting them too.

    – user285603 Dec 30 '13 at 15:56
  • @user285603 But can you move the child folders of the parent folder, not the folder with the space? – Thor Dec 30 '13 at 15:57
  • @user285603 Then, the steps above should hopefully help you out, if you're interested in trying. – Thor Dec 30 '13 at 16:12
  • THIS DIDN'T WORK.

    Remove-Item .*

    – user285603 Dec 30 '13 at 16:15
  • @user285603 Remove-Item .\* didn't work when you were in the folder above the " "-folder? Try Remove-Item .\* -Force, it might help depending on what happened. – Thor Dec 30 '13 at 16:16
  • still didn't work – user285603 Dec 30 '13 at 17:02
  • 1
    The OP wants to rename it, not remove it, presumably because he wants to keep things in it... – Izkata Dec 30 '13 at 20:03
  • Aye. That is why Thor had step 1). As I read it the idea was to get the stuff out of the folder, then remove the empty folder. – Hennes Dec 31 '13 at 00:14
  • @Hennes OP said in the question that he can't, and I read Thor's step 1 as moving things that are siblings to the "space" folder, so that * didn't match them. – Izkata Dec 31 '13 at 09:31