Scott Hanselman

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

July 30, '14 Comments [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
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, July 30, 2014 6:36:10 AM UTC
Now that is a nice little tip! I always had to use the console for that little job!

Thanks Scott and Mads
Scott Guymer
Wednesday, July 30, 2014 6:36:17 AM UTC
Thanks. That's easier than opening cmd and using move to rename a file.
Donatas
Wednesday, July 30, 2014 7:01:15 AM UTC
Sweet, thanks for sharing!
Joakim
Wednesday, July 30, 2014 7:05:45 AM UTC
Thank you Mr. Hanselman,

You saved my life :)

Mattias
Wednesday, July 30, 2014 7:26:10 AM UTC
Awesome guy, Mads, isn't he :)
Serban
Wednesday, July 30, 2014 7:34:32 AM UTC
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
Martin Kirk
Wednesday, July 30, 2014 8:24:08 AM UTC
Nice! I always used to open a command prompt and run "echo foo > .foo"
Peter
Wednesday, July 30, 2014 9:27:55 AM UTC
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.

Wednesday, July 30, 2014 9:58:23 AM UTC
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.
Peter DC
Wednesday, July 30, 2014 11:46:52 AM UTC
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
tmik
Wednesday, July 30, 2014 2:08:49 PM UTC
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!
Wednesday, July 30, 2014 3:12:17 PM UTC
Nice little tip, thanks for sharing!
Wednesday, July 30, 2014 3:40:19 PM UTC
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.
Chad Levy
Wednesday, July 30, 2014 3:57:36 PM UTC
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.
WilNosg
Wednesday, July 30, 2014 4:56:33 PM UTC
Some of us "old timers" have known about this trick for a while. :)

http://serverfault.com/a/22628/729
Wednesday, July 30, 2014 5:56:56 PM UTC
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
Rahul
Wednesday, July 30, 2014 8:34:37 PM UTC
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!
Steve Tibbetts
Wednesday, July 30, 2014 10:18:51 PM UTC
Sweet!
Dave
Wednesday, July 30, 2014 10:27:04 PM UTC
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
Thursday, July 31, 2014 6:13:43 AM UTC
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.
Citronas
Thursday, July 31, 2014 6:54:48 AM UTC
Thanks scott :) well-done
Sirwan
Thursday, July 31, 2014 6:57:26 AM UTC
The good old command prompt also works fine:
ren test.txt .test
Robert van Weersch
Thursday, July 31, 2014 12:50:16 PM UTC
Or you can go the programmer way ;)
echo. 2>.gitignore
Thursday, July 31, 2014 11:35:46 PM UTC
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?!?
Phil
Friday, August 01, 2014 2:01:21 AM UTC
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.
Monday, August 04, 2014 7:52:19 PM UTC
Thanks for sharing!
Crazy Frog
Thursday, August 07, 2014 3:20:27 PM UTC
Really curious why this was implemented in this way.
DanT
Wednesday, August 13, 2014 4:07:30 PM UTC
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...)
JustDave
Saturday, August 16, 2014 4:44:03 PM UTC
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.
Friday, August 29, 2014 7:52:56 AM UTC
Awesome tip.

Thanks
Thursday, September 04, 2014 5:02:49 PM UTC
Weak - why did you remove the "poop" reference? That was the best part of this post.
Drew Miller
Comments are closed.

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