Scott Hanselman

How to create a file with a . dot prefix in Windows Explorer

July 30, 2014 Comment on this post [31] Posted in Tools
Sponsored By

If you right click in Windows and try to make a new text file with a . period/dot in front of it:

image

Name the file...something like .gitignore, for example.

image

You'll get the "You must type a file name" error.

image

But, rather than typing .gitignore, if you include an ending dot also, like

.gitignore.

Then it works fine.

image

Thanks, Mads, for the tip!

NOTE: We're assuming that you have "File name extensions" turned on, because if you don't, you're likely not a programmer. ;)

image

UPDATED: Mads has created an "Add Empty File" Extension for VS that makes it easy to create . files as well!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 30, 2014 10:36
Now that is a nice little tip! I always had to use the console for that little job!

Thanks Scott and Mads
July 30, 2014 10:36
Thanks. That's easier than opening cmd and using move to rename a file.
July 30, 2014 11:01
Sweet, thanks for sharing!
July 30, 2014 11:05
Thank you Mr. Hanselman,

You saved my life :)

Mattias
July 30, 2014 11:26
Awesome guy, Mads, isn't he :)
July 30, 2014 11:34
Now show us some more Kung-Fu... and name a file or folder one of these names: CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9,
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9

I dare you...

My brain cast a LegacyClusterfuckException
July 30, 2014 12:24
Nice! I always used to open a command prompt and run "echo foo > .foo"
July 30, 2014 13:27
Nice,
Not sure if anyone is interested but I've been using a program Called Total Commander from ghisler.com for more years than I care to remember, even though I'm primarily a windows developer I barely touch windows explorer (still sour at microsoft for taking away the File Manager from windows 3.11 haha).

To create a file there it's SHIFT+F4 enter .test and it will put you in your fav text editor.

Recommend this to everyone that are keyboard and short-cut fans, if you love your mouse then it's probably not for you.

Brian.

July 30, 2014 13:58
Um not sure which version of windows you guys are using but on my version of 8.1 I have no issues naming a file beginning with a period. Folders however still give the same error and that fix works.
July 30, 2014 15:46
Please note that you need to have "Hide extensions for known file types" unchecked in your system settings. Otherwise typing file name like Scott did would give a result of ".gitconfig..txt" instead of ".gitconfig"
Also this is a reason why it seems to work for @Peter DC, but under the hood it's not what you wanted. Nevertheless, great little tip.

M
July 30, 2014 18:08
Wouldn't be better if instead of Error, Windows pop-ups yes/no dialog? Like:
Yes - I want "file without name"
No - Let me correct it

Brian,
+1 for Total Commander! I am using it for 10+ years and still rocks!
July 30, 2014 19:12
Nice little tip, thanks for sharing!
July 30, 2014 19:40
I typically use Notepad++ for this. Type "notepad++ .gitignore" in the Explorer address bar while viewing the directory you want to create the file and Notepad++ will create the file and let you edit it.

Great tip, though. Sometimes it's nice to just create the file and mess with it later.
July 30, 2014 19:57
Like Chad Levy said:
Open a notepad and save the document, but surround the name with quotation marks, i.e. ".gitignore". You will get the same. You just have to navigate to the directory, but nothing that couldn't be handled by copy & paste.
July 30, 2014 20:56
Some of us "old timers" have known about this trick for a while. :)

http://serverfault.com/a/22628/729
July 30, 2014 21:56
If you have the Unix sub system utilities, shipped with Win 7, deprecated in (Win 8 or 8.1 don't recall), you can try touch.exe <.poop>

http://www.microsoft.com/en-us/download/details.aspx?id=274
July 31, 2014 0:34
Love your site Scott, keep up the good work!

I do have one piece of feedback; the example pictures/text given isn't as clear as it could be. You change the target example text 1/2 way through the example (from .pooop to .gitignore). It would be more clear to the reader if .pooop was used throughout. This would remove a variable during the explanation and lead to a higher level of clarity. As it stands now, you have to read the text(teh horror) and examine the images to understand the solution. Really, the pictures could tell the whole tale if the example text was consistent.

I see this A LOT when reading examples of code on the internet, even printed in some books.

This is just nit-picky really, just wanted to throw it out there for you Scott!
July 31, 2014 2:18
Sweet!
July 31, 2014 2:27
Well that's a bit hidden!

@Scott, can you get Microsoft to include an "I am a developer" check-box on windows somewhere, they could allow this stuff to just happen!! They can turn off the "hide extensions" option by default too...

PK :-D
July 31, 2014 10:13
I'm also using Total Commander for years. The only reason I use the Windows Explorer is to burn DVDs, like an iso file once a year.
July 31, 2014 10:54
Thanks scott :) well-done
July 31, 2014 10:57
The good old command prompt also works fine:
ren test.txt .test
July 31, 2014 16:50
Or you can go the programmer way ;)
echo. 2>.gitignore
August 01, 2014 3:35
I had a copy of our default .gitignore file in One Note, but when you copy it it renames it to .gitignore.gitignore, because despite my actions Windows 'really' knows what I 'really' want I am trying to do?!?
August 01, 2014 6:01
One has to question why Explorer considers this to be an error in the first place. It is almost as if the programmer who wrote the code for this error message did not understand what legal filenames are. After all, the attempted file DOES have a name, and a perfectly legal one at that.
August 04, 2014 23:52
Thanks for sharing!
August 07, 2014 19:20
Really curious why this was implemented in this way.
August 13, 2014 20:07
Kudos to the guys using Total Commander.

It's just one of those programs .....you never leave home without.

(gotta give Peter Norton credit for first addicting me...)
August 16, 2014 20:44
I was doing this with my .bowerrc files until a friend told me I could just use the following command:

touch .bowerrc


Provided you have git installed.
August 29, 2014 11:52
Awesome tip.

Thanks
September 04, 2014 21:02
Weak - why did you remove the "poop" reference? That was the best part of this post.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.