Why do some file/folder names on Windows have a dot in front of them?
2014-07
For example, in My Documents
, there are the following folders:
.ssh
.subversion
Is this some sort of naming convention that I am unaware of?
This naming convention comes from Unix-like operating systems, where it means a "hidden" file or directory. It works anywhere, but its primary use is to hide configuration files in your home directory (e.g. ~/.cache/
or ~/.plan
– they're frequently called "dotfiles").
Dotfiles could, in a way, be called the traditional Unix equivalent to the "AppData" directory on Windows. (Meanwhile, many Linux programs are being changed to follow the XDG base directory specification, moving their configuration to ~/.config/
and other data to ~/.cache/
& ~/.local/share/
– this makes it a little more similar to AppData\Roaming
and AppData\Local
.)
You have these .ssh
and .subversion
directories on Windows, because you've used some programs – specifically, OpenSSH and Subversion – that have been ported to use Windows system APIs rather than POSIX ones, but haven't been adjusted for some other Windows conventions.
Sometimes this adaptation is skipped intentionally, to make life easier for people who use Unix-like environments such as Cygwin on their Windows systems. For example, Cygwin installs the standard set of Unix-like tools like ls
, which ignores the Windows "hidden" flag, and only honors the .dotfile
names. Also, it is easier to synchronize configuration between one's Windows and Linux/BSD/OSX computers if it is shared in the same location.
Also: Typically these files are in the user's home directory, e.g. /home/name/.ssh
on Linux, or C:\Users\name\.ssh
on Windows 7+. It is quite rare for them to be put in the "Documents" or "My Documents" subdirectories... they do not contain documents after all.
As Rob Pike writes on Google+, this was an accidental feature:
Long ago, as the design of the Unix file system was being worked out, the entries
.
and..
appeared, to make navigation easier. I'm not sure but I believe..
went in during the Version 2 rewrite, when the file system became hierarchical (it had a very different structure early on). When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this:
if (name[0] == '.') continue;
This statement was a little shorter than what it should have been, which is
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue;
but hey, it was easy.
Two things resulted.
First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted.
Second, and much worse, the idea of a "hidden" or "dot" file was created. As a consequence, more lazy programmers started dropping files into everyone's home directory. I don't have all that much stuff installed on the machine I'm using to type this, but my home directory has about a hundred dot files and I don't even know what most of them are or whether they're still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.
This naming convention comes from Unix-like operating systems, where it means a "hidden" file or directory.it always appear in in every file and evry OS.
Many programs needs folder names that starts with a dot, like .emacs.d, .gimp-2.2, .jedit etc. How do I create such a folder?
When using the Windows Explorer in Windows 2000 (and other versions), I get an error message saying "You have to enter a filename". The only solution I have come up with, is to open a command prompt (Start, Run, "CMD", OK) and enter "mkdir .mydir".
Why have Microsoft this error message in the Explorer, but not in the command shell? Is there any registry hack out there to fix this, so that I am able to enter the folder name directly in the Explorer?
To create/rename on windows explorer, just rename to .name.
- The additional dot at the end is necessary, and will be removed by Windows Explorer.
To create a new file begins with a dot, on command prompt:
echo testing > .name
You can create a folder using the Command Prompt with:
mkdir .foldername
You can create a file using command prompt with:
echo.>.filename.extension
Use any file browser other than Explorer (Shell). I have tested with WinRAR, 7-Zip ect. For example, open WinRAR, then navigate to your files or folders, click on it, press F2 (rename), put a .
at beginning, Done! I have tested with both WinRAR and 7-Zip. You don't need to add to Zip or make a compressed file.
The simpler method I found in other answer, just put a .
at the end too.
Windows (Explorer) does not allow you to create a folder that starts with a dot ('.'). This is for security/exploit reasons. However, it is possible (as you noted) to create the folder manually using the Command Prompt.
So, if your question was how to do it in native Windows Explorer, the answer is no -- You cannot.
Use Windows Powershell. Otherwise this is not possible with DOS/Explorer - only method is to create foo.bar and then rename with the explorer window.
With Powershell you can
touch .bak
successfully.
Just download Anyclient and Fast Folder Rename. Fast folder rename will name a folder .whatever, using the replace feature. Anyclient will upload the folder and show it, even though it operates on a Windows system.
Open a Command Prompt window and enter the following commands:
cd /path/to/the/file
ren file.extension .file.extension
That worked for me.
You can do it with powershell cmdlet New-Item.
Open PowerShell console and enter
For File: New-Item .whatever -type file
For Folder: New-Item .whatever -type directory
Just name your file with additional dot at the end: ".ext." explorer will remove additional dot and you'll get .ext file.