I named a folder the character for space, and now that I've switched over to Windows I need to rename it

14

3

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?

user285603

Posted 2013-12-30T15:23:00.283

Reputation: 141

11Switch back to linux and rename it? – Raystafarian – 2013-12-30T15:25:38.637

1That is a workaround, not a solution. Though it may well be the fastest way if you got a liveCD lying around. – Hennes – 2013-12-30T15:27:02.570

no, i don't have a live CD. – user285603 – 2013-12-30T15:33:01.047

1

I am not sure it is possible.

http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx states "Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not."

A single space also counts as ending with a space. :(

– Hennes – 2013-12-30T15:34:26.863

Maybe you can avoid the normal Windows shell and user interface by using a different API. E.g. prepend \?\ to paths works to get around some of the normal explorer limits such as the max 260 chars in a directory path. I did not test it with spaces nor do know how to get from this possible starting point to a nice answer.

(Example: [start][run]\\?\D:\test opens the folder D:\test). – Hennes – 2013-12-30T15:41:55.353

@user285603 Your best bet is making a live CD then – pratnala – 2013-12-30T15:41:58.763

@user285603 For clarification, can you move the contents of the parent folder somewhere else, so that you can try my (hopeful) answer? – Thor – 2013-12-30T15:54:04.390

Thor: no, i cant move the parent folder. – user285603 – 2013-12-30T16:12:08.210

2Install Cygwin. – Daniel R Hicks – 2013-12-30T17:06:37.127

Believe I hit something similar once - open Powershell and try renaming it from that. – Mark Allen – 2013-12-30T21:33:03.613

Of course, this begs the question: what legitimate reason would one have for naming a folder ? :) – apnorton – 2013-12-30T21:35:43.043

Answers

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

Posted 2013-12-30T15:23:00.283

Reputation: 23 855

but no way of renaming the folder? – user285603 – 2013-12-30T16:50:10.307

3The above shows the folder being renamed. – JdeBP – 2013-12-30T16:54:27.793

2Just to clarify it a way more: The unix way of renaming a file is to m o v e it to a new name. – Hennes – 2013-12-30T17:23:46.550

Oh...yeah, tried to use it... WAY too complicated for me. – user285603 – 2013-12-30T17:50:11.267

7

@user285603 you just need to download SUA, install it and then run the commands provided here. That's not that hard! What were you expecting? A magic word?

– terdon – 2013-12-30T18:57:53.317

@user285603 I ran into the reverse problem with early windows versions. Way to complicated. At least the nix way is simple and straight forward. One simple tool per task. :) – Hennes – 2013-12-31T00:13:00.887

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

Posted 2013-12-30T15:23:00.283

Reputation: 953

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

Posted 2013-12-30T15:23:00.283

Reputation: 15 151

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 – 2016-01-19T01:43:47.207

3Nitpick 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 – 2013-12-30T16:45:31.593

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

Posted 2013-12-30T15:23:00.283

Reputation: 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 – 2016-01-06T05:10:06.953

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 – 2016-01-06T06:31:19.473

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 – 2016-01-06T08:08:30.040

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 – 2016-01-06T13:25:02.050

What do you mean that the OS is doing the right thing? – Motivated – 2016-01-06T22:43:29.270

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

Posted 2013-12-30T15:23:00.283

Reputation: 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

Posted 2013-12-30T15:23:00.283

Reputation: 3 562

From the OP: "I can't move anything in the folder." – Hennes – 2013-12-30T15:50:07.447

@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 – 2013-12-30T15:50:56.787

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 – 2013-12-30T15:51:40.867

@Hennes We'll just have to wait and see! – Thor – 2013-12-30T15:54:43.943

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 – 2013-12-30T15:56:58.830

@user285603 But can you move the child folders of the parent folder, not the folder with the space? – Thor – 2013-12-30T15:57:32.553

@user285603 Then, the steps above should hopefully help you out, if you're interested in trying. – Thor – 2013-12-30T16:12:41.867

THIS DIDN'T WORK.

Remove-Item .* – user285603 – 2013-12-30T16:15:50.413

@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 – 2013-12-30T16:16:59.093

still didn't work – user285603 – 2013-12-30T17:02:15.923

1The OP wants to rename it, not remove it, presumably because he wants to keep things in it... – Izkata – 2013-12-30T20:03:40.420

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 – 2013-12-31T00:14:09.690

@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 – 2013-12-31T09:31:42.947