# Of Spaces, Underscores and Dashes

**URL:** <https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835>\
**Category:** blog\
**Created:** [April 26, 2006, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835 "2006-04-26T00:00:00Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![Josh](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/j/45deac/32.png) [@Josh](https://discourse.codinghorror.com/u/Josh)\
**Post date:** [May 19, 2006, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/21 "2006-05-19T00:00:00Z")

</div>

There is one downside to using ‘-’ over ‘\_’. The former is commonly used in language. What about double barrel names for example?

Camilla Parker-Bowles  
Camilla\_Parker-Bowles  
Camilla-Parker-Bowles

Now I’ve lost the difference between ’ ’ and ‘-’. I think Bit-Jockey makes a great point but sadly, I still use underscores. A habit I just can’t break, mainly because spaces really suck in Urls.

---

<div class="post-metadata">

**Author:** ![L505](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/l/dfb087/32.png) [@L505](https://discourse.codinghorror.com/u/L505)\
**Post date:** [October 1, 2007, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/22 "2007-10-01T00:00:00Z")

</div>

File names and folder names are not sentences. I always laugh when people bring up the prose arguments. Apples and oranges. File names and procedures/functions in programming languages are short little blurbs of text. They are not English sentences. There is plenty of whitespace all over your screen and between windows/scrollbars/wasted space areas. In English text, there is not plenty of whitespace inside the paragraph.

So please, don’t compare apples to oranges. The same arguments are used in programming languages. Cee programmers tend to argue that underscores are easier to read. I find that the underscores add more symbols to the already symbol infested obfuscated Cee code.

Let me repeat: file names and folder names are not English sentences.

Your first and last name is not an English sentence either. JohnDoe or John-Doe or John\_Doe is just as easy to read. If we were discussing English sentences, then john\_doe\_went\_to\_the\_park\_to\_see\_trees would be easier to read. But we are not discussing English sentences.

If your file and folder names are becoming so long that they are English sentences, then you need to rename them. My Program Files In That Cool Windows Directory is not a good folder name.

---

<div class="post-metadata">

**Author:** ![freddyzdead](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/f/278dde/32.png) [@freddyzdead](https://discourse.codinghorror.com/u/freddyzdead)\
**Post date:** [October 8, 2007, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/23 "2007-10-08T00:00:00Z")

</div>

I am not a programmer, so this issue doesn’t impact me on that front. The reality is that encountering a name with substitutes for spaces offends all my esthetic sensibilities; it just looks hideous, especially the underscores. Usability also goes down the drain with anything that requires such frequent use of the shift key.

Probably this would be a non-issue except for stone-age, intolerant Unix. We can also blame Microsoft, Apple and all the rest of the computing world for implementing long filenames without carefully considering all the implications. This is part of the ongoing campaign to make computers “user friendly” so they can be operated by complete novices, but it has resulted in a giant tower of Babel.

As happens each time everybody sits in their corner and does their own thing, we now have a big mess which will probably never be resolved.

I agree with the above comment that computers are supposed to work for us; we shouldn’t be required to adapt our lifestyle to suit them.  
In this case, the number of space-intolerant scenarios is relatively small, so it is illogical that we all have to modify our behaviour to cater for them.

In situations like this, a de facto standard usually emerges and saves the day. Since none of the conventions being used today is acceptable, this unfortunately doesn’t look like happening any time soon.

---

<div class="post-metadata">

**Author:** ![Ira](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/i/9fc348/32.png) [@Ira](https://discourse.codinghorror.com/u/Ira)\
**Post date:** [October 24, 2007, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/24 "2007-10-24T00:00:00Z")

</div>

While I agree its very annoying to put spaces in file paths and your Google dashes finding is very interesting and compelling, I just found out how to pass references to annoying file paths in Outlook 2003.  
Enclose the path in angle brackets. Its fabulous. It can be done after pasting in the horrid path.

---

<div class="post-metadata">

**Author:** ![ObaO](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/o/94ad74/32.png) [@ObaO](https://discourse.codinghorror.com/u/ObaO)\
**Post date:** [December 28, 2007, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/25 "2007-12-28T00:00:00Z")

</div>

Wow. All I wanted was supporting arguments to choose a naming convention here at the office. Given that 99% of the lusers are ignoratti, the space is here to stay. So I can now see based on the above arguments, that actually it is historically developer’s fault for not making the use of space in filename easier for programmers to work with.

All those back up scripts, etc. need to be hand coded to handle space names. Why? Because developers were so callous(sp?) as to select the language-text space char as the code separator. Should actually be some other funky (read non-printing) thinggy like chr(9) A Tabb for anyone?

Go figure, we always blame the luser, when they do the most natural thing. In this case lusers are correct, and OS/dev languages are incorrect, they should find a diffrent ‘standard’ to using the space (maybe keyboards should have to ‘space’ bars eh? One for ‘text’ space and oine for ‘code’ space - hey my new invention for the Unicode world!!!

---

<div class="post-metadata">

**Author:** ![Ken](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/k/cc9497/32.png) [@Ken](https://discourse.codinghorror.com/u/Ken)\
**Post date:** [March 12, 2008, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/26 "2008-03-12T00:00:00Z")

</div>

Sometimes you don’t get to pick your tools, and they have bugs that make use of spaces problematic. Try calling a post-build script from Visual C++ 6 with an argument that contains a space, for example. Not possible.

A space in a filename is generally a clue that you need to add a level of directory hierarchy. Instead of “My Documents”, use “Documents/Mine”. Instead of “2008 Acme Invoices”, try “Invoices/Acme/2008”. Spaces are semantic separators in English. In directory hierarchies, the equivalent token is the slash/backslash.

---

<div class="post-metadata">

**Author:** ![Cal](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/c/f1d935/32.png) [@Cal](https://discourse.codinghorror.com/u/Cal)\
**Post date:** [August 6, 2008, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/27 "2008-08-06T00:00:00Z")

</div>

Personally, I really hate spaces embedded in directory and file names.  
I am a programmer so, granted, I am looking at it from that perspective.

uSoft cannot even get it right though. For example, HP mounts CF and  
SD cards under \SD Card and \CF Card on their versions of PocketPC.  
Try passing full PocketPC pathnames with embedded spaces as args to  
any of the CMD shell work-alikes in .bat files under PocketPC! It’s  
a mess!! %1 becomes \SD and %2 becomes Card... – every .bat  
file you code has to deal with that crap. I gave up programming for  
PocketPC mostly because of that annoyance (and the lack of support  
for the most basic concept of PWD - current or present working dir.

Very interesting discussion about this topic here, though, lottsa  
varied ideas. The good news is that the HTML world hates looking at  
%20 as much as I hate seeing embedded spaces in my directory and file  
names. I generally use the underbar as a replacement for separation,  
but the Google discovery seems to suggest that maybe dashes or dots  
would be better.

---

<div class="post-metadata">

**Author:** ![PhilipT](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/p/838e76/32.png) [@PhilipT](https://discourse.codinghorror.com/u/PhilipT)\
**Post date:** [February 6, 2010, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/28 "2010-02-06T00:00:00Z")

</div>

Hey, dashes-to-make-a-long-identifier-is-lisp-style! (Or possibly Scheme.)

For myself, I have come to use dots as a handy compromise: they’re not in the middle of the line like a dash, and they are not considered a word character like an underscore, nor are they escaped in URLs.

Since this area is far more personal preference than anything else, I feel quite justified in my choice. :)

---

<div class="post-metadata">

**Author:** ![Aaron\_Jones](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/a/d9b06d/32.png) [@Aaron\_Jones](https://discourse.codinghorror.com/u/Aaron_Jones)\
**Post date:** [February 6, 2010, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/29 "2010-02-06T00:00:00Z")

</div>

For file and directory names or anything that might be used in a URL, I agree with Jeff about this, all-lower-case-hyphenated-words work best.

A friend of mine used to say “the shift key is cumbersome and often unnecessary”. In the debate over underscores vs. hyphens for file names I definitely agree with his statement.

Hyphens are less keystrokes, you benefit with the google/word seperator issue, the underlined hyperlink confusion issue, and a side benefit of adding a lower case convention is that you won’t hit case sensitivity issues when moving files back and forth between windows and unix/linux/mac machines. I got hit by that once and vowed it wouldn’t happen again.

I didn’t realize the regex connection before reading this post. Now I have even more defense of my hyphen-reasoning. Thanks!

---

<div class="post-metadata">

**Author:** ![Adeelcap15](https://discourse.codinghorror.com/letter_avatar_proxy/v2/letter/a/f4b2a3/32.png) [@Adeelcap15](https://discourse.codinghorror.com/u/Adeelcap15)\
**Post date:** [March 4, 2010, 12:00am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/30 "2010-03-04T00:00:00Z")

</div>

@jeff reading your this comment,  
This\_is\_a\_single\_word  
but this-is-multiple-words  
…

I have searched in google with keyword **web-site** , but google considered it one word.

---

<div class="post-metadata">

**Author:** ![vpfaiz](https://discourse.codinghorror.com/user_avatar/discourse.codinghorror.com/vpfaiz/32/76663_2.png) [@vpfaiz](https://discourse.codinghorror.com/u/vpfaiz)\
**Post date:** [May 1, 2020, 4:55am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/32 "2020-05-01T04:55:24Z")

</div>

I usually put what ever is acceptable. For example as long as we are not using it in code (sql/shell) spaces are fine (SharePoint, Excel, Windows files, etc). If you are using in uri (URLs, ARNs, etc) then hyphen is fine and if it is used in code then underscore… 😎

I guess it all boils down to readability and write-ability

---

<div class="post-metadata">

**Author:** ![codinghorror](https://discourse.codinghorror.com/user_avatar/discourse.codinghorror.com/codinghorror/32/36371_2.png) [@codinghorror](https://discourse.codinghorror.com/u/codinghorror)\
**Post date:** [January 7, 2025, 6:39am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/33 "2025-01-07T06:39:09Z")

</div>

Closed on January 7, 2025, 6:39am UTC



---

<div class="post-metadata">

**Author:** ![JimPas](https://discourse.codinghorror.com/user_avatar/discourse.codinghorror.com/jimpas/32/76163_2.png) [@JimPas](https://discourse.codinghorror.com/u/JimPas)\
**Post date:** [May 29, 2025, 5:23am UTC](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835/34 "2025-05-29T05:23:55Z")

</div>

Opened on May 29, 2025, 5:23am UTC



[Previous page](https://discourse.codinghorror.com/t/of-spaces-underscores-and-dashes/835.md?page=1)
