What is the best way to represent spaces in file names?
October 26, 2007 11:43 PM   Subscribe

What is the best way to represent spaces in file names?

This has been a question for a long time. What is the best way to represent a space in file names? I am looking the way that is either the "standard practice", "best practice", or "most capable". I want a way that lets me not run into problems when switching between an Apple, Windows, or Linux system. Suggestions?

Periods?

file.name.txt

Spaces?

file name.txt

Underscores?

file_name.txt

Dashes?

file-name.txt
posted by chrisalbon to Technology (26 answers total) 4 users marked this as a favorite
 
If you can't do spaces then underscores are considered the norm... there are obviously older UNIX systems out there which don't do spaces... underscores are the cleanest way to represent the same typographical function while allowing advanced end users the option to swap out later. Anything else is messy.
posted by wfrgms at 11:49 PM on October 26, 2007


And by "swap out" I mean it is way easier to do a find-replace on "_" than "." or any other symbol.
posted by wfrgms at 11:51 PM on October 26, 2007


Underscores are safe, but they look ugly as hell to me. Dashes also work, but they are sometimes used in their own right, which can lead to confusion. Periods are an accident waiting to happen, some - esp. older - systems/programs ( you know who you are ) won't handle a filename with two periods properly.

Most modern systems will handle plain spaces properly, maybe with the addition of escapes or quote characters for you shell, but now and then you come accross some bozo programmer who didn't take this into account.

All things considered, I'd say underscores or dashes. As a data point, most linux distros use dashes to separate components in package names.
posted by the number 17 at 11:57 PM on October 26, 2007


wfrgms, I'm pretty sure UNIX systems have handled spaces in filenames since day zero (but short filename length limits were common through, oh, the late '80s sometime).

I would avoid dots, colons, semicolons, slashes, and backslashes, but other than that go wild.
posted by hattifattener at 12:09 AM on October 27, 2007


I think most IT type people avoid spaces because if you need to use the name in a command line, you have to escape the spaces or quote the filename, which is cumbersome and aesthetically displeasing.

e.g. cd /Documents\ and\ Settings/user/My\ Documents/My\ Music/

If you don't think your files will be used in that context, go ahead and use spaces. Everything supports them these days except for ancient systems, and if you're going for compatibility with those you might as well just use 8.3 filenames.

I'd avoid underscores as I also concur that they're pretty ugly. Dashes are the best non-space option, in my opinion.
posted by zixyer at 12:11 AM on October 27, 2007


There isn't really an answer for "best".

Pick one convention and use it consistently.
posted by aubilenon at 12:15 AM on October 27, 2007


From someone who has "converted" countless PC files to EBCDIC, please, for the love of "insert $_Deity", pick something and stick to it. I strongly suggest the use of underscores to replace "spaces" in PC file names.
posted by paulsc at 12:20 AM on October 27, 2007


underscores.
posted by rhizome at 12:27 AM on October 27, 2007


If you want your filenames to be easily handled programaticaly - say by a regexp breaking them into words, or to restore the spaces by replacing - underscore is really the best option, as it is very rarely used otherwise.

However, as an added personal gripe, I hate having to shift to type the underscore: coordinating the two key presses between left and right hand breaks the rythm.

Also, what aubilenon said.
posted by the number 17 at 12:42 AM on October 27, 2007


Underscores. This leaves the hyphen open for other types of breaks. Like for instance:

A_picture_of_kittens-v1.jpg
posted by wemayfreeze at 12:48 AM on October 27, 2007 [1 favorite]


Why wouldn't you use underscores? I don't know of a particular standard (there may well be one somewhere), but it's practically standard. I don't find something so blatantly functional ugly.

As for filename length, that has little to do with Unix per se and everything to do with compact filesystems on tiny storage media.
posted by dhartung at 1:15 AM on October 27, 2007


I reckon CamelCase because you can see it even if it's a link in a word document, and you avoid any little foibles and keeping it short, in case it gets trunc~
posted by b33j at 1:21 AM on October 27, 2007


I'll join everyone else in saying, spaces are safe, but always underscores when you don't want spaces.
posted by abcde at 1:47 AM on October 27, 2007


Why wouldn't you use underscores?

They're not super easy to type, especially on laptop keyboards. It's quicker to type a hyphen (although my personal preference is certainly underscores).

I guess this really underscores the lack of filename conventions. (I have no shame or regrets about my puns.)
posted by spiderskull at 2:17 AM on October 27, 2007


Spaces are safe until you have some bloody program stick %s in the middle of it. Underscores work great, unless you load your file to the web, and people try and disemminate it through printed material using MS Word, which invariably underlines URLs, effectively hiding your underscores (or spaces).

I've had software as recently as yesterday object to the length of a name and shorten it to 8 characters. On the other hand, I've come across files (saved by other people) with all kinds of stupid punctuation including quotes and question marks. Don't do that. Don't be that person.
posted by b33j at 2:21 AM on October 27, 2007 [1 favorite]


Underscores, the choice of champions.
posted by Divine_Wino at 6:39 AM on October 27, 2007


%20

Just do yourself the favor of being consistent.
posted by geekyguy at 7:20 AM on October 27, 2007


I use underscores. I considered whether I was being "too careful" and whether spaces were just as good -- then I remembered how file names with spaces get munged when presented in a URI -- and noticed that this wasn't just annoying to me, but also made communicating with others trickier. So I'm sticking with underscores.
posted by amtho at 7:26 AM on October 27, 2007


seconding CamelCase.

thisFileNameConventionIsTheBestForMe
posted by chrisamiller at 7:30 AM on October 27, 2007


Underscores
posted by drezdn at 7:53 AM on October 27, 2007


IDon'tLikeThisFileNameSoMuch, ThisIsATSElliotPoem, ...Etc
posted by StickyCarpet at 7:57 AM on October 27, 2007


dhartung writes "Why wouldn't you use underscores? I don't know of a particular standard (there may well be one somewhere), but it's practically standard. I don't find something so blatantly functional ugly."

An underscore is a pain in the hand to type.

I use CamelCase or occasionally periods. CamelCase has the advantage of reducing the number of characters needed to type, doesn't get munged like spaces on the web and doesn't get obscured like underscores or periods in brain dead applications like Word.
posted by Mitheral at 9:21 AM on October 27, 2007


This comes up a bit more in programming because variables can't have spaces.

I always used CamelCase until I started using Ruby where underscores seem to be the norm. I think underscores are more readable.
posted by bitdamaged at 9:28 AM on October 27, 2007


underscores.
posted by fishfucker at 12:12 PM on October 27, 2007


CamelCase is bad and you should feel bad for using it. Underscores.
posted by dame at 12:16 PM on October 27, 2007 [1 favorite]


I read somewhere on the interweb that google treats a dash a space but not an underscore. "white_bread" and "white-bread" are different.

So, being a web designer and not a programmer, I started using dashes.
posted by kpmcguire at 6:16 PM on October 27, 2007


« Older What do you get the guy whose seen everything?   |   Black Gold, Texas Tee Time! Newer »
This thread is closed to new comments.