The "_" character.

Syncopator

Registered
This question may be technically OT (and I'm not really a Unix or X11 guy), but I figured this might be the best place to ask this question:

Can anybody tell me why people insist on using the "_" character in file names? Tons of people -- from software developers to the average guy who takes vacation photos -- seem to believe that they must avoid using the space character, resulting in tons and tons of ugly file names.

Why take the trouble to type "My_Grand_Canyon_Vaction.jpg" -- which is (a) more difficult to type, (b) looks ugly, and most importantly (c) wraps incorrectly on the desktop -- when "My Grand Canyon Vaction.jpg" would do just fine?! The same goes for PDFs, disk images, and the like. (See attached screen shot.)

Is there some legit reason for doing this -- like some (past or present) Windows limitation on using spaces? A friend says it might be a holdover from the days of DOS, which didn't allow spaces in file names. Is he correct, or is there some other reason? Then again, Macs have *never* prohibited spaces, yet many of the files I'm talking about come from Mac developers! So why would a Mac developer ever need to name Mac files in such a way?

Bottom line: In 2006, is there any legit reason to avoid spaces in file names, or is this practice basically a technological "superstition" that has no real basis? No doubt there's nothing that can really be done about it, but if anyone has any info, I'd love to hear about it.

Thanks.
 

Attachments

  • Picture 2.jpg
    Picture 2.jpg
    44.2 KB · Views: 15
There's not much reason. It makes it easier to type into the command line, though. If a file has spaces, you either need to wrap it in quotes, or use the escape sequence "\ ".

Also, when dealing with URLs, spaces are a no-no. My_Grand_Canyon_Vacation may look worse than "My Grand Canyon Vacation", but when we're dealing with URLs, those spaces will be replaced by "%20". And "My%20Grand%20Canyon%20Vacation" is bloody infuriating to read. So I use underscores in anything I intend to upload to a web site.

I can only assume older incarnations of Unix-bases OSes had more problems with these things than OS X.

Aside from that, I think it's just a matter of style. Believe it or not, some people have gotten so used to underscores for one reason or another that it seems more natural in file names.


And perhaps a more relevant question regarding the wrapping issue is, why doesn't Apple acknowledge underscores as word breaks?!
 
Thanks for the reply. For the record, I definitey was *not* referring to URLs. I'm aware of the "%20" issue. I was only talking about files -- files that are intended for the average user to download.

Just seems like an arcane practice -- and I bet most people who do it don't even know why they do it; they've just seen it elsewhere, and they think it's something they have to do, as well.

Thanks again.
 
because they are for download. if i've uploaded an image to my web server, it's often a screen grab, which mac os likes to name Picture 4.png, for example. this is irritating from a web stand point on two counts, as to get to this file without making a webpage for it (ie typing the exact url into the address bar), it would have to be capitalised, as well as having %20 in it.

so i'd have to type "anotherwebsite.net/Picture%204.png" every time i'd want to access it, which is not very natural, and just annoying. (look how many capital letters i use on a day to day basis(!)
 
I almost always use the underscore, even for native files on my Mac.

I use linux webservers and spaces in file names require extra work and thought. (Same on the Mac itself.)

If I'm using ssh and I want to delete a file on the server and its name contains spaces I have to type rm ./"file name.jpg".

If I type rm ./file name.jpg I'll get a "file not found" error

Unix/Linux only parses to the space unless you enclose the filename containing spaces within quotes. Spaces in file names create all kinds of minor hassles when you work with the command line. I find it easier to just avoid them.

edit:

I guess it's important to understand that space is a very important character in *nix. It separates arguments in commands, for example...

tar cvzf foo.tgz source_folder

That command tells *nix to create a gzipped archive (foo.tgz) of a directory (source_folder). The spaces separate the arguments.

All *nix commands follow the same rule.
 
Syncopator said:
I bet most people who do it don't even know why they do it.

It's not a superstition, but a matter of aesthetics.

If you're programming and can chose to type:

vi my\ program.f90

versus

vi my_program.f90

or

vi myprogram.f90

the first one is deemed ugly.

I can see how this "_" naming scheme doesn't work well for viewing files as icons, but it seems to be fine for viewing in the finder as Lists or Columns.
 
spb said:
It's not a superstition, but a matter of aesthetics.

If you're programming and can chose to type:

vi my\ program.f90
Now you open a whole other can of worms for the non techie user.

It's important to understand that the backslash (\) tells *nix to interpret the following character literally, do not evaluate it. So the \(space) means an actual space, not a argument separator.
 
mikuro already mentioned that in the second post, though, so it's not _really_ another can of worms... Isn't there a tool of some sort that can automatically rename files so that underscores in the filenames are translated to spaces? I guess one could whip up an Apple(or other)Script for that.

I have to say, I _do_ tend to use underscores instead of spaces in filenames that are not meant for the 'net, too. I often name files like this: "20060514_macosx.txt" ... But I guess it's really just how I'm used to handle that. Then again, should I ever have to quickly upload the file somewhere and someone else needs the link, it's much easier then. Of course I could simply rename the file _then_, but if I automatically create names like that, that's fine, too, for me..
 
simbalala said:
It's important to understand that the backslash (\) tells *nix to interpret the following character literally, do not evaluate it. So the \(space) means an actual space, not a argument separator.

Really? Ah, using a slash is doing something very different from using the name in quotations. I avoid programming sh (hurray for PERL) so I didn't think about this difference. You make a good point.

The are both effective work arounds for files with annoying spaces in the names. :7)
 
Also, using spaces can cause issues with some more archaic software scripts. Take eCopy Server (a PC hooked up to a copy machine that scans documents and emails them to you as a pdf). If you name the outgoing pdf with a space, (my file.pdf) it emailed you "my", dropping everything after the space, including the file extension.

It's always just been safe practices. Certain standards are upheld simply for the .5% of those out there for whom it would be a problem. Eventually they go away (when was the last time you shortened a document's filename to less than 8 characters before you emailed it?)
 
Yeah, basically, it's for backwards compatibility with CLI stuff. It's largely needless, but it's an easy trap to fall into. Also a consideration for people who move files back and forth on FAT32 devices (most thumb drives, for instance); the underscore is permitted in the FSes of all versions of Windows and DOS.

Spotlight returns 6413 Documents on my HDD with an underscore.
 
Back
Top