Create/rename a file/folder that begins with a dot in Windows?

474

113

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?

Adventure10

Posted 2009-11-02T15:15:03.640

Reputation:

Related post on SO - How to manually create a file with a . dot prefix in windows for example .htaccess

– RBT – 2019-03-22T05:35:28.847

I encountered a similar problem when creating files. Some files were namedcom4.txt, com1.txt etc and those are reserved names for devices, so it crashed my software. – Zimano – 2020-02-12T16:00:29.690

6This is an ancient protection built into windows explorer and dates back to the time that only DOS 8.3 filenames were available (Win 3.1) and files with just an extension were not allowed. Microsoft never bothered to remove this from the Explorer, probably because humans using the Explorer should be "protected" from accidentally creating files without a filename (i.e., only extension). – None – 2009-11-02T15:22:13.527

14

See also "How do I rename a file to .htaccess in Windows 7?" at http://superuser.com/questions/56562/how-do-i-rename-a-file-to-htaccess-in-windows-7/

– Arjan – 2009-11-02T15:30:29.240

Answers

658

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

Denny

Posted 2009-11-02T15:15:03.640

Reputation: 6 685

69Works on Windows 10 - @Denny where did you find this gold nugget?! – Daniel Sokolowski – 2015-05-29T01:52:10.963

3@Denny How did you know this? Is it a feature or a very useful bug? – Buttle Butkus – 2015-10-29T21:36:12.140

2@ButtleButkus (not meant to disparage anyone) ...I would imagine that he knew this because he is older than 30 and had to make his way in the Long-Long-Ago; in the Before Time when theres was no Interwebz. Try this little ditty from your command line echo times >> .foo & < nul (set /p s=gaz) >> .foo & echo intas >> .foo & type .foo and you will see 2 lines printed to the screen times and gazintas – K. Alan Bates – 2016-01-19T16:15:21.090

5@K.AlanBates I don't see an explanation in your comment regarding the trailing dot. What does age or the internet have to do with this syntactical phenomenon? – isherwood – 2016-10-17T18:33:53.333

if you get "The system cannot find the file specified." when trying to rename/move, make sure the file or folder isn't hidden! (attrib -h .setting && move .setting .new-setting) – matt wilkie – 2016-11-11T21:54:48.237

4@K.AlanBates - A little less patronisation, a little more explanation please. – Hashim – 2017-08-14T01:10:38.790

Works with windows 2008 R2 SP1, which is the server equivalent of Win7. Thank you OP and @Joe White – Jon Grah – 2017-10-04T10:20:42.923

echo on > .name (or echo off > .name) creates an empty file. – Nuno André – 2018-07-28T05:26:40.587

1@Hashim The original DOS convention for filenames was FILENAME.EXT where the dot separator was always present at least implicitly to separate the name from the extension. For backwards compatibility or tradition, Windows still works like this, so any filename ending with a . is the same as the name itself. For example "abc." is the same as "abc", as is "abc..", "abc..." and so on. On Unix-like systems these are all distinct filenames, but on Windows they are not. – Brandin – 2018-09-26T10:43:08.563

For those keeping score, this is confirmed to work in Windows Server 2012 – cdkMoose – 2019-10-08T19:15:21.647

This is the most useful thing I will learn this decade – GabrielBB – 2020-01-19T18:45:31.883

For those keeping score, this is confirmed to work in Windows Server 2016 – dmikester1 – 2020-01-29T18:22:59.987

16I just tried .name. in Windows (XP) and it did not work; it complained about needing a filename. – Synetech – 2012-06-24T16:54:19.243

65Confirmed to work on Windows 7. That's awesome. – Joe White – 2012-06-30T21:26:51.200

49Confirmed to work on Windows 8. – Mr. Polywhirl – 2013-01-24T03:38:40.567

2Confirmed to work on Windows Vista. Amazing. – Hope4You – 2013-01-26T17:21:14.043

11Only option to create in XP is thru command prompt. say mkdir .name – Antony Thomas – 2013-05-08T18:05:13.797

Or even simply echo. > .name! – mythofechelon – 2013-10-03T09:01:50.493

59

You can create a folder using the Command Prompt with:

mkdir .foldername

You can create a file using command prompt with:

echo.>.filename.extension

quickmana

Posted 2009-11-02T15:15:03.640

Reputation: 591

33

Good question. There is an easy way to do this from Windows Explorer without using a command prompt or shell. Suppose you want to create a folder called: ".apple"

  1. Create a New Folder from Windows Explorer as you normally would.
  2. When prompted to enter a name, type: ".apple." (notice the dot at the end)

Windows should create a folder called: ".apple"

Please note that I've used this only on Windows 7. I am not sure if other versions of Windows support this.

P.S. Chris Moschini says in a comment that it works in Windows 10.

Aamer

Posted 2009-11-02T15:15:03.640

Reputation: 331

6Works in Windows 10. – Chris Moschini – 2017-09-13T17:52:08.513

1

this was exactly the same as the top voted answer in this question, only 4 years later

– phuclv – 2018-06-15T01:24:10.483

You have just saved my life, I accidentally rename all folders and files from my Windows User folder and my programs started to fail. Fortunately i was able to reset the names. +1e6 votes up. – Rafa Barragan – 2018-07-26T23:24:45.463

14

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.

Shafeer

Posted 2009-11-02T15:15:03.640

Reputation: 141

6

Open a Command Prompt window and enter the following commands:

cd /path/to/the/file
ren file.extension .file.extension

That worked for me.

user216626

Posted 2009-11-02T15:15:03.640

Reputation: 61

5

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

Michael Hicks

Posted 2009-11-02T15:15:03.640

Reputation: 51

Yeah, in Powershell 4.0 also works with "md" command. – Fernando Gonzalez Sanchez – 2014-10-16T19:26:50.850

4

Total Commander does it in visual manner.

Boris Pavlović

Posted 2009-11-02T15:15:03.640

Reputation: 155

3

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.

lonstar

Posted 2009-11-02T15:15:03.640

Reputation: 276

this is definitely possible. Did you look at the most voted answer which was posted several months before yours?

– phuclv – 2018-06-15T01:27:19.587

2

I couldn't create .bowerrc. So

First, I created bowerrc Then, to a dos prompt I said:

>powershell
PS > ren bowerrc .bowerrc
PS > exit
>

Joe Codeswell user601770

Posted 2009-11-02T15:15:03.640

Reputation: 129

1you dont even need powershell. just plain old cmd (see other answers) - Powershell definitely works though :) – Nick – 2016-03-22T06:45:22.443

1

Windows does allow this. Open Windows Explorer. Now on the right-click context menu -> New -> Folder. Type the name of your folder both starting with a dot(.) and ending with a dot(.) and the trailing dot is removed when saved e.g. .test. becomes .test

OpinionatedChas

Posted 2009-11-02T15:15:03.640

Reputation: 19

3

How is this answer different from this answer 6 years before?

– Franklin Yu – 2018-05-16T23:33:48.723

2

also this answer from 2 years before

– phuclv – 2018-06-15T01:25:48.647

1

My favorite way to do this: I have ConEmu installed and integrated into the Windows context menu. https://stackoverflow.com/questions/21852965/open-in-conemu-right-click-menu-windows-7

When I need to rename a file to one with the dot I choose "ConEmu here" from the context menu, then type:

ren name .name

Can also be used with echo method above.

Benefits:

  • Quick and easy, doesn't take you out of context too much.
  • No need to type D: enter cd D:\\____\\_____\\_______\\____
  • No need to install software you wouldn't otherwise (I like and use ConEmu for various purposes).

Gru

Posted 2009-11-02T15:15:03.640

Reputation: 11

0

It is possible to create .jedit file/folder on Windows. Please create it with two dots (like .jedit.) and the last dot will be removed automatically.

Abbas Arif

Posted 2009-11-02T15:15:03.640

Reputation: 1

0

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.

Jagtig

Posted 2009-11-02T15:15:03.640

Reputation: 1

4links to the utilities would be very useful – Jhonny D. Cano -Leftware- – 2011-08-11T17:14:52.200

-4

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.

Anthony M. Powers

Posted 2009-11-02T15:15:03.640

Reputation:

1How do you do it from the command line? – Buttons840 – 2011-11-16T20:13:32.973

20> Windows (Explorer) does not allow you to create a folder that starts with a dot ('.'). This is for security/exploit reasons.   Huh? In what way? – Synetech – 2012-06-24T16:55:40.320

5I second Synetech comment - if it is for "security/exploit reasons" then we need to call up Linus Torvald ASAP and tell him to plug this hole yesterday! – Natalie Adams – 2012-10-12T02:56:28.940