4

A dot (.) can be part of a file or directory name including the first and last position. On UNIX a single dot in a path refers to the current directory and can thus always be resolved to a directory whose name is not ..

Is there some way that I can create a directory which is named . on Windows?

8
  • 1
    why do you want to do that? In PowerShell you'll see `.` all the time to indicate the current folder. Less common in cmd but still the same meaning
    – phuclv
    May 6, 2019 at 16:38
  • @phuciv I don't want to do it, users of the software my team is developing might. May 6, 2019 at 20:04
  • Windows allows directories to be named with a preceding dot, but only via CLI on many Windows editions (i.e. .ssh, .gnupg, etc.). I'm not certain on when the functionality was added to File Explorer in Win10, but v1903 does allow this through File Explorer as well. If your question is can a directory simply be named ., no, as no OS allows this because a single . is an alias for the current directory, just as .. is an alias for the preceding directory.
    – JW0914
    Sep 7, 2019 at 13:24
  • 1
    @JW0914 Windows allows directories to be named with a preceding dot, but only via CLI on many Windows editions that's incorrect. You can create directories and files with a preceding dot like I commented. The final dot will automatically be removed and you'll get .ssh, .gnupg as expected
    – phuclv
    Sep 7, 2019 at 13:29
  • 1
    @JW0914 I haven't, but others have and I've read how to do that from the internet. That's because all names in the Win32 namespace technically have an invisible dot at the end
    – phuclv
    Sep 7, 2019 at 13:32

2 Answers 2

9

No. A single dot means the current directory and 2 dots mean the parent directory, just like on *nix

  • Use a period as a directory component in a path to represent the current directory, for example ".\temp.txt". For more information, see Paths.
  • Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory, for example "..\temp.txt". For more information, see Paths.

Naming Files, Paths, and Namespaces

In fact a more general rule is that no file can end with a dot in Windows

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. However, it is acceptable to specify a period as the first character of a name. For example, ".temp".

See

The reason is because they'll be normalized when passing to Win32 APIs

Some characters will be removed (other than runs of separators and relative segments).

If a segment ends in a single period, that period will be removed. A segment of a single or double period falls under the relative component rule above. A segment of three periods (or more) doesn't hit any of these rules and is actually a valid file/directory name.

If the path doesn't end in a separator, all trailing periods and spaces (charater [sic] code 32 only) will be removed. If the last segment is simply a single or double period it falls under the relative components rule above. This rule leads to the possibly surprising ability to create a directory with a trailing space. You simply need to add a trailing separator to do so.

Path Normalization

That doesn't mean that those files can't be created though, because NTFS namespace is fully POSIX-compatible. You just need to append the \\?\ prefix to disable file name normalization

For file I/O, the "\?" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system

Naming Files, Paths, and Namespaces

See also

-1

The single dot means the same in MS Operating systems as well. Open a CMD prompt, and type dir . as an experiment. So, the answer to your question is, no.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.