Windows Explorer – why at-character @ sometimes is not allowed in filenames?

6

5

I knew many restricted and special characters in file and folder names that impossible to use, or they can cause trouble later.

For example putting a dot at the end of the name will cause it to disappear.

Explorer itself has more restrictions, for example a dot at the beginning of filename is very hard to put.

OK, but what's wrong with at-sign @ !?
I didn't saw anywhere any restrictions about it, nor could I find it now.

See:

1) Open Windows Explorer and create a file or folder with name 1,1
2) Press F2 and rename it to @1,1
3) See? New name was cancelled.

My question is: WHY?

I tested this "feature" on XP, Win7 and Win10.
Funny thing in WinXP is that renaming 0,0 to @0,0 actually renames it to @0.

Looks like this is internal Explorer behavior, because in CMD console it is perfectly fine to do cd.>"@1,1"

aleksusklim

Posted 2017-11-04T06:59:15.863

Reputation: 63

I just tried this on Windows 7, and I can’t reproduce your result — I can rename a file, with Explorer, to a name that includes @, with no problems. – Scott – 2017-11-04T07:04:47.143

@Scott, it is somehow related to comma , especially if there is a numeric after it. @ must be the first character. Did you try my specific example? Hmm it also may be locale-dependent… I have Russian locale where , is separator for real numbers (1,5 means 1 and a half, not 1.5 as in English locale). – aleksusklim – 2017-11-04T07:10:18.627

I did now.  I took a PNG file and renamed it to @0,0.png, and then to just plain @0,0.  I got the warning about changing an extension, but when I hit OK, the rename worked.  (I am in USA.) – Scott – 2017-11-04T07:14:45.923

@Scott, Well, I cannot create @1,1.png Looks like locale is related. Did you try @1,1 (since @0,0 is buggy only for XP, in Win7 and later it renames fine), or maybe you'll try @1.1 ? Not sure it will show that, though. – aleksusklim – 2017-11-04T07:19:43.360

1Ah, now I am getting weird results. Based on 42 seconds of testing, it looks like attempts to rename to @1,1 silently fail (leaving the name unchanged). – Scott – 2017-11-04T07:26:18.777

A "why" question like this, which is in essence asking what Microsoft's designers were thinking when they decided this, is generally very hard to answer. At the root of it, Explorer is reluctant to let you use a @ because it was designed that way. But why it was designed that way... very few people will know. – Corrodias – 2017-11-04T10:28:20.477

@Corrodias, Actually, my "why" also means "is there anything other related to this, what I also need to consider?". For example, I perfectly know what I will face if I'd use symbols like % & ^ in filenames (good luck to manage them in CMD later...), and I know what exactly causing that problems. But here I have no idea why @ behaves so strangely, so I don't know what other use of it I should be afraid of. – aleksusklim – 2017-11-04T10:36:57.710

Answers

8

I don't know why Explorer forbids such renames, but it's likely to do with a localization feature.

Various parts of Explorer use the @<DllName>,<ResourceID> syntax for dynamically loading localized text – see registry string redirection. (Note that the resource ID is always a decimal number, often negative.)

  • For example, the description for .lnk shortcuts in Registry is @shell32.dll,-4153, which means "load string with ID -4153 from file shell32.dll". Since DLL files can have a separate resource table for every supported language, the resulting description will be translated to whatever display language Windows is set to.

  • Similarly, your Desktop; Documents; Pictures; ... directories have a hidden desktop.ini file containing:

    [.ShellClassInfo]
    LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21769
    IconResource=%SystemRoot%\system32\imageres.dll,-183
    

    When Explorer sees this file, it won't just show the folder as "Desktop" – it will show the translated name.

Simply using the redirection syntax in an actual file/directory name won't do anything, but my guess is that it was forbidden to prevent various bugs in case a program mixes up the "real" and "display" names in some manner. (For example, if you name a directory @shell32.dll,-21769, it is possible that a buggy program will keep trying to access Desktop instead. This might even create security issues.)

So that would be similar to various other names which Windows allows but Explorer does not (e.g. .foo which is a regular "hidden file" for Unixen, but can be mistaken for a nameless (extension-only) file by some Windows programs).

user1686

Posted 2017-11-04T06:59:15.863

Reputation: 283 655

3Oh my god, indeed! Why didn't I thought of that. Hey, now I actually tried to rename test directory to @shell32.dll,-21769 in WinXP Explorer, and it magically "renamed" it to visual name Рабочий стол ("Desktop" in Russian) which contains desktop.ini with LocalizedResourceName=@shell32.dll,-21769 line. When I tried to rename a file test – Explorer created desktop.ini right here with [LocalizedFileNames] and test=@shell32.dll,-21769. (Also, that "localized name" stuff by itself may be so-o-o confusing for a novice user, and could be possibly used by malware). – aleksusklim – 2017-11-04T14:20:04.657

Thanks for your edits and clarifying. So, I guess, I will use _@_ file prefix instead or my old @_ one. Actually, it was my naming scheme for downloaded video files: sometimes I make a backup copy of a video so I can safely delete it to save space; but often I don't want to delete it immediately since I didn't watch it yet. So, I used to put @_ prefix to the filename, so I could easily distinguish backuped ones. Lately I found a file which had the size in the name, in form like "Video (1,5 Gb).mp4" – then my scheme is failed on @_ Video (1,5 Gb).mp4. – aleksusklim – 2017-11-04T16:43:16.347