Reply
Thread Tools Display Modes
#1
Old 10-22-2012, 10:50 AM
Guest
Join Date: Jul 2010
Posts: 3,084
What's the straight dope regarding spaces in file names?

I've been using Windows and Linux systems for years and I've never had a problem. I like spaces for readability purposes but I've also been told that they should be avoided. So, what's the straight dope? Is my computer going to blow up some day?
#2
Old 10-22-2012, 10:55 AM
Guest
Join Date: Sep 2012
Location: Midcoast Maine, USA
Posts: 809
Quote:
Originally Posted by standingwave View Post
I've been using Windows and Linux systems for years and I've never had a problem. I like spaces for readability purposes but I've also been told that they should be avoided. So, what's the straight dope? Is my computer going to blow up some day?
Computer isn't going to blow up, but spaces in file names can require extra steps to get things to work in the command line (like putting it in quotes so it doesn't think the part after the space is part of a command parameter).

For readability purposes, I begin each new word with a capital letter and avoid spaces. (EnglishEssayOne.txt instead of English Essay One.txt). A document without spaces is more easily viewed on the web as well (I don't have to remember to use %20 or whatever it was in the URL in place of the space).
#3
Old 10-22-2012, 10:57 AM
Guest
Join Date: Dec 1999
Posts: 1,571
Where did you hear that spaces should be avoided? I've been using spaces for years with never a problem. Of course, things like forward slashes and the like must be avoided, but the computer won't let you use them anyway.

I liked DOS, but am not at all nostalgic for that 8 character limit in file names.
#4
Old 10-22-2012, 10:58 AM
Guest
Join Date: Oct 2007
Location: rhode island
Posts: 38,826
You may difficulty using some utilities and applications, or accessing the files from other systems that do not recognize spaces in file names. However your computer will blow up if you insert a special *bomb* character in a file name. This is character is entered with the special key combination ctrl+alt+left arrow.
#5
Old 10-22-2012, 11:00 AM
Guest
Join Date: Jul 2009
Posts: 5,917
Quote:
Originally Posted by standingwave View Post
I've been using Windows and Linux systems for years and I've never had a problem. I like spaces for readability purposes but I've also been told that they should be avoided. So, what's the straight dope? Is my computer going to blow up some day?
You've probably used Windows and Linux in a graphical user interface environment, or else you already know the appropriate work-arounds in a command line interface (CLI) environment.

In most CLIs, the space is a word separator: it breaks up different "entities", such as distinct option or file parameters.

Like this:

wc -l foo bar baz

wc is the command
-l is an option
foo, bar, and baz are presumed to be three distinct files.

If your intent was to treat "foo bar baz" as a single file, you'd have a little trouble getting the shell (CLI interpreter) to understand that, since it assumes that the spaces are separators, not parts of the single filename you meant.

In most Linux shells, you can "escape" the spaces (tell the shell "this space isn't for you, it's part of the filename") with a backslash in front of each:

wc -l foo\ bar\ baz

or wrap the whole filename in quotes, also telling the shell that the quotes are the part of the single filename (actually, telling the shell "whatever's inside the quotes, it's a single filename"):

wc -l "foo bar baz"

This latter trick works in Windows command lines, as well.

Stuff that gets interpreted "in the background" by tools that operate by CLI shell rules, like some web stuff, also falls afoul of the "spaces are seperators unless you tell me otherwise" rule.
#6
Old 10-22-2012, 11:02 AM
Guest
Join Date: Jul 2009
Posts: 12,056
SPACE in a file name might require the file name to be in quotes to be accepted.

when operating in MS-DOS window the SPACE is not a valid character.
#7
Old 10-22-2012, 11:18 AM
Guest
Join Date: Jun 2003
Location: Tel Aviv
Posts: 5,877
If all you're doing is creating and reading files on a GUI, spaces are fine.

If you need to do anything that uses the file names as data, you need to go through hoops in order to use filenames that include spaces (and some other special characters as well)

My rule of thumb is that filenames should include letters, digits, and the Underscore -- which can be used instead of a Space character is having some daylight between words is important to you.

Contrast

FileNameWithAFewWords.txt

File Name With A Few Words.txt <-- This frankly makes my eyes hurt! But maybe it's just me.

File_Name_With_A_Few_Words.txt

I fail to see a major visual difference between the second and third options. Do yourself a favor and use an underscore whenever you feel you really, absolutely need to put a space in a file name.
#8
Old 10-22-2012, 11:22 AM
Charter Member
Join Date: Apr 2003
Posts: 25,865
I use periods instead of underscore between words in filenames. This is for files used exclusively by Windows PCs. Is there any problem with doing so?
#9
Old 10-22-2012, 11:27 AM
Guest
Join Date: Jun 2003
Location: Tel Aviv
Posts: 5,877
Quote:
Originally Posted by Dewey Finn View Post
I use periods instead of underscore between words in filenames. This is for files used exclusively by Windows PCs. Is there any problem with doing so?
Probably not any more, but if you run into some really ancient software that expects a file name to look like <name>.<suffix> then you could run into a bit of trouble. Not likely in this day and age (note I don't think one has to accommodate the possibility of a program requiring a 3-letter suffix any more!) but better safe than sorry.
#10
Old 10-22-2012, 11:30 AM
Charter Member
Join Date: Apr 2003
Posts: 25,865
Yes, but most of those programs are also going to expect eight-character filenames.
#11
Old 10-22-2012, 11:34 AM
Guest
Join Date: Jul 2010
Posts: 3,084
Quote:
Originally Posted by gnoitall View Post
You've probably used Windows and Linux in a graphical user interface environment, or else you already know the appropriate work-arounds in a command line interface (CLI) environment.

In most CLIs, the space is a word separator: it breaks up different "entities", such as distinct option or file parameters.

Like this:

wc -l foo bar baz

wc is the command
-l is an option
foo, bar, and baz are presumed to be three distinct files.

If your intent was to treat "foo bar baz" as a single file, you'd have a little trouble getting the shell (CLI interpreter) to understand that, since it assumes that the spaces are separators, not parts of the single filename you meant.

In most Linux shells, you can "escape" the spaces (tell the shell "this space isn't for you, it's part of the filename") with a backslash in front of each:

wc -l foo\ bar\ baz

or wrap the whole filename in quotes, also telling the shell that the quotes are the part of the single filename (actually, telling the shell "whatever's inside the quotes, it's a single filename"):

wc -l "foo bar baz"

This latter trick works in Windows command lines, as well.

Stuff that gets interpreted "in the background" by tools that operate by CLI shell rules, like some web stuff, also falls afoul of the "spaces are seperators unless you tell me otherwise" rule.
This helps. Thanks. Yeah, I started back in the bad ol' days with Dos and when CLIs came out, I never looked back. I will on occasion resort to the terminal when necessary, but I'm seldom happy about it.
#12
Old 10-22-2012, 11:35 AM
Guest
Join Date: Dec 2009
Location: The Land of Smiles
Posts: 16,419
I wish we were in BBQ Pit, because long filenames with special characters make me want to puke. I do a lot of "command line" work, and the characters need to be escaped.

Also annoying is the way Windows makes filename extensions invisible, in some situations.

BTW, twenty-odd years ago a friend was writing a story using WordStar. He asked me for help because, although he kept saving the latest version, it in fact was soon overwritten with an earlier version, and he had to re-enter text. The problem was a space in his filename: one WordStar dialog could handle the space, another couldn't.
#13
Old 10-22-2012, 11:39 AM
Guest
Join Date: Jun 2003
Location: Tel Aviv
Posts: 5,877
Quote:
Originally Posted by septimus View Post
Also annoying is the way Windows makes filename extensions invisible, in some situations.
[Hijack]Yeah, fuck Redmond up the ass with a red-hot poker for *this*. The first thing I do (probably, literally the first thing) on a new Windows box is start up File Explorer and disable the "hide known suffixes" feature bug.

Oh, and the second thing I do is install some other browser.
[/hijack][/rant]
#14
Old 10-22-2012, 11:59 AM
Charter Member
Join Date: Oct 1999
Location: Shakedown Street
Posts: 12,955
I tried adding backspaces to a filename, but got an error message that it was too short.
#15
Old 10-22-2012, 01:55 PM
Guest
Join Date: Dec 2009
Location: The Land of Smiles
Posts: 16,419
Quote:
Originally Posted by Noone Special View Post
[Hijack]Yeah, fuck Redmond up the ass with a red-hot poker for *this*. The first thing I do (probably, literally the first thing) on a new Windows box is start up File Explorer and disable the "hide known suffixes" feature bug.

Oh, and the second thing I do is install some other browser.
[/hijack][/rant]
I didn't know this was an option.
... And Googling now, it appears it is some absurd 2-step option.

I'd start a BBQ Pit thread explaining why Unix was(*) infinitely superior to Windows except
SPOILER:
I know from experience the most computer-illiterate Dopers would show up, shrilly defending Windows.

(* - I write "was" rather than "is", because in some perverse race-to-the-bottom, the Linux user interface is evolving to emulate the Windows "philosophy" as closely as possible. )
#16
Old 10-22-2012, 02:02 PM
Guest
Join Date: Jun 2003
Location: Tel Aviv
Posts: 5,877
Quote:
Originally Posted by septimus View Post
I didn't know this was an option.
... And Googling now, it appears it is some absurd 2-step option.
If you just want to disable this... behavior... permanently (Assuming Windows 7), open Explorer, "Organize", "Folder and Search Options", Switch to "View" tab, uncheck the "Hide extensions for known file types" check box, and Cello! (er, viola! ... or something )

Quote:
I'd start a BBQ Pit thread explaining why Unix was(*) infinitely superior to Windows except
SPOILER:
I know from experience the most computer-illiterate Dopers would show up, shrilly defending Windows.

(* - I write "was" rather than "is", because in some perverse race-to-the-bottom, the Linux user interface is evolving to emulate the Windows "philosophy" as closely as possible. )
Actually, Windows 7 / Server 2008 are both decent (not great) operating systems. The "DOS emulation" shell still sucks for getting down-and-dirty with the internals, however.
#17
Old 10-22-2012, 02:03 PM
Charter Member
Join Date: Oct 1999
Location: Sturgeon Bay, WI USA
Posts: 20,408
Quote:
Originally Posted by Noone Special View Post

FileNameWithAFewWords.txt

File Name With A Few Words.txt <-- This frankly makes my eyes hurt! But maybe it's just me.

File_Name_With_A_Few_Words.txt

I fail to see a major visual difference between the second and third options. Do yourself a favor and use an underscore whenever you feel you really, absolutely need to put a space in a file name.
Seconded. While you might like periods or spaces between words, the underscore symbol is the only safe one, rooted in computing antiquity.

And while we're at it, very long filenames can cause problems, too. Stay below 64 characters; 32 is even better. If you need more, you're probably misusing the concept of a name. Write your essay in the body of the file, not the title!
#18
Old 10-22-2012, 02:24 PM
Member
Join Date: Aug 2002
Location: Deep Space
Posts: 43,458
Amen to most of the above. I work on UNIX systems, and just last week I wrote a script to convert really ugly filenames (not just spaces but parens and # also) to something reasonable. I'll be automatically downloading a ton of these things, and don't want to have to bother quoting or escaping them to do anything useful.
#19
Old 10-22-2012, 02:34 PM
Guest
Join Date: Dec 2003
Location: Boulder, CO
Posts: 499
Quote:
Originally Posted by Dewey Finn View Post
I use periods instead of underscore between words in filenames. This is for files used exclusively by Windows PCs. Is there any problem with doing so?
I don't think modern Windows will have any problem, but some mail filter software might object if you try to send any of those files as attachments. A common tactic of viruses which spread by email is to attempt to hide their true extension, so they appear to be harmless: Funny-cat-video.mpg.exe <- really an executable, not a video versus First.quarter.report.xls <- totally legit email attachment.

I'm not saying you will see these problems, but in an attempt to prevent viruses so new they are not yet in definition files, blocking on "suspicious" names is a strategy some mail filters take.
#20
Old 10-22-2012, 03:22 PM
Guest
Join Date: Mar 2007
Location: Miskatonic University
Posts: 10,310
Quote:
Originally Posted by echoreply View Post
I don't think modern Windows will have any problem, but some mail filter software might object if you try to send any of those files as attachments. A common tactic of viruses which spread by email is to attempt to hide their true extension, so they appear to be harmless: Funny-cat-video.mpg.exe <- really an executable, not a video versus First.quarter.report.xls <- totally legit email attachment.

I'm not saying you will see these problems, but in an attempt to prevent viruses so new they are not yet in definition files, blocking on "suspicious" names is a strategy some mail filters take.
It's funny, if I send a .tar.gz via gmail it warns me "the usual extension for a file of this type is .tar.gz, not .gz, would you like to fix before sending?" If I say yes it "fixes" the file to a .tar.tar.gz.
#21
Old 10-22-2012, 05:05 PM
Guest
Join Date: Dec 1999
Location: Texas
Posts: 6,658
Quote:
Originally Posted by Noone Special View Post
[Hijack]Yeah, fuck Redmond up the ass with a red-hot poker for *this*. The first thing I do (probably, literally the first thing) on a new Windows box is start up File Explorer and disable the "hide known suffixes" feature bug.
Yes, me too. The very first thing I do on a new Windows installation is to turn off that damn option to suppress the display of file name extensions.

I can't figure out why that's even an option, but what I really don't get is that it's been the Windows default setting for years. I think maybe Windows 95 was the first time I saw it.
#22
Old 10-22-2012, 05:56 PM
Charter Member
Join Date: Mar 2002
Location: NY but not NYC
Posts: 30,095
Quote:
Originally Posted by Noone Special View Post
Contrast

FileNameWithAFewWords.txt

File Name With A Few Words.txt <-- This frankly makes my eyes hurt! But maybe it's just me.

File_Name_With_A_Few_Words.txt

I fail to see a major visual difference between the second and third options. Do yourself a favor and use an underscore whenever you feel you really, absolutely need to put a space in a file name.
As another veteran of 8 character file names I always use spaces today in naming. Any system that required me to put in an underscore would see it fly through a window.

I'm trying and trying and I cannot imagine any universe in which underscores would be preferred by anyone.

Quote:
Originally Posted by Musicat View Post
And while we're at it, very long filenames can cause problems, too. Stay below 64 characters; 32 is even better. If you need more, you're probably misusing the concept of a name. Write your essay in the body of the file, not the title!
I use file names like Florence [SC] Evening News - Monday, October 21, 1935, p1 pt2.JPG all the time. They are as long as they need to be, so 32-64 characters are the norm. I don't even understand your objection.
#23
Old 10-22-2012, 06:22 PM
Guest
Join Date: Dec 2003
Location: Boulder, CO
Posts: 499
Quote:
Originally Posted by Exapno Mapcase View Post
I use file names like Florence [SC] Evening News - Monday, October 21, 1935, p1 pt2.JPG all the time. They are as long as they need to be, so 32-64 characters are the norm. I don't even understand your objection.
The maximum path+filename length in Windows is something like 260 characters (except when it's 32k, but the details are technical). A 40 character filename is not a big deal, but combine it with a few 50-100 character directory entries and you have problems. The places I've seen people run into this is when they have a verbose filename and directory structure, and then they copy it into "Backup for January - July 2012" or some such, which pushes them over the edge. They then get weird errors, like they can see the files and copy them, but not open them.

You are far better off using a filename which is verbose enough to be descriptive to you of what the file is, than so terse that you lose things. There is a limit though.
#24
Old 10-22-2012, 06:24 PM
Guest
Join Date: Jul 2010
Posts: 3,084
Quote:
Originally Posted by Exapno Mapcase View Post
I use file names like Florence [SC] Evening News - Monday, October 21, 1935, p1 pt2.JPG all the time.
Well, for dates I use 19351021 or maybe 1935-10-21. That way, not only are they compact, they also sort.
#25
Old 10-22-2012, 06:44 PM
Guest
Join Date: Jul 2004
Location: Pittsburgh
Posts: 12,088
Quote:
Originally Posted by standingwave View Post
Is my computer going to blow up some day?
Yes, it is. When I find it and blow it up to get rid of all the filenames with spaces. I write Unix shell scripts, and filenames with spaces make my life difficult. I hate them and want to blow up every computer that hosts them.
#26
Old 10-22-2012, 06:45 PM
Charter Member
Join Date: Oct 1999
Location: Sturgeon Bay, WI USA
Posts: 20,408
Quote:
Originally Posted by Exapno Mapcase View Post
I'm trying and trying and I cannot imagine any universe in which underscores would be preferred by anyone.
They would be preferred if backwards compatibility is a consideration.
Quote:
I use file names like Florence [SC] Evening News - Monday, October 21, 1935, p1 pt2.JPG all the time. They are as long as they need to be, so 32-64 characters are the norm. I don't even understand your objection.
The ISO 9660 standard has some limits:
Quote:
The restrictions on filename length (8 characters plus 3 character extension for level 1) and directory depth (8 levels, including the root directory) are a more serious limitation of the ISO 9660 file system. Many CD authoring applications attempt to get around the filename length by truncating filenames automatically, but do so at the risk of breaking applications that rely on a specific file structure. The Rock Ridge extension works around the 8 directory depth limit by folding paths. In practice however, few drivers and OSes care about the directory depth, so this rule is often ignored. ISO Level 2 allows longer names, but since the total directory entry uses a single byte it is limited to 255 bytes. This puts upper limit on the filename of just over 200 characters depending on what directory extensions are used.
While 200 characters might not seem like a severe restriction, I have run across modern (post-Windows 3.1) programs that don't like any more than 64 characters. I can't remember just what those were offhand.

And your sample file name would cause problems in my 2012 version of a video server, the machine that handles broadcast files for our cable channel. Give it a comma, and it goes apeshit. It's a Linux box inside, so that might be the reason.

There is indeed an art to the creation of file names, and integration with folders or directories is even more art. If you find yourself naming 1000 files in the same folder all beginning with "League of Women Voters...", as a friend of mine does, Perhaps it's time to re-think your storage and make a directory just for the League's files. That way, you don't have to repeat it each time and file names can be more meaningful.

And there's nothing more annoying than to look at a filename list, most of which are 20 characters or so, and find one that's 65. It makes the column display jump into a wide mode just for a single name, and other names cannot be displayed for lack of space without extensive scrolls. There are other places to store all that auxiliary data than a file name.

These may seem like trivial considerations, but when you work with millions of files (well, at least 50TB, not all online at once) and have to be able to find a single one on demand, the organization becomes critical.

And standingwave's "sort" comment is also relevant.
#27
Old 10-22-2012, 06:51 PM
Guest
Join Date: Sep 2011
Location: Sunny California
Posts: 14,840
Put me down for being of conservative philosophy about file naming conventions.

Spaces is a file name should be considered a definite BAD idea. They are commonly acceptable today, but you can never be sure just how files names will be used, or what pieces of software will or won't work with them. (See anecdote below.)

Dots in files names likewise. These generally seem to work okay these days, but you never know when you'll run across some app that chokes on them, as in several examples shown above.

Hyphens in file names seem to work fine. I'm not aware of any problems with this.

Underscores in file names: These work fine and always have. It's your choice whether to use them or not. VeryLongFileName.txt or Very_Long_File_Name.txt -- take your pick.

I think that names without underscores are the more popular, at least among programmers I've talked to, e.g., VeryLongFileName.txt -- A bit of computer jargon: This is called CamelCase.

Anecdote about how odd names can cause trouble in ways you didn't expect: Since this post is long enough, I'll write a separate post about this.

ETA: Also beware: If there's any chance your file will be used or transmitted to or from any machine other than your own: Beware of case conventions. Some machines (in particular, all flavors of Microsoft DOS, Winders, and similar) are case-insensitive about names. Unix, Linux, and all derivatives thereof are case-sensitive. Just keep that in mind when you choose names for files.

Last edited by Senegoid; 10-22-2012 at 06:54 PM.
#28
Old 10-22-2012, 07:05 PM
Guest
Join Date: Mar 2007
Location: Miskatonic University
Posts: 10,310
I have to say, the programmer in me names everything without spaces because I don't want to have to deal with having to take the special considerations for spaces when writing scripts for myself.

Then when it comes time to actually WRITE the script I get paranoid and make sure to handle spaces anyway.

Last edited by Jragon; 10-22-2012 at 07:06 PM.
#29
Old 10-22-2012, 07:08 PM
Guest
Join Date: Sep 2011
Location: Sunny California
Posts: 14,840
Anecdote about how oddball file names can bite you later on, in ways you maybe didn't expect.

TRUE STORY.

A certain grocery wholesaler produces data files with product pricing information, to be downloaded by retailers (supermarkets) and imported into their cash register POS systems. There are three to eight such files each week, with longish names.

Those POS systems in the store are a cash register application, written by a small company where I used to work. This POS system is capable or running add-on modules written in a home-grown scripting language. I am fluent in that scripting language. Now I do 3rd-party consulting for a dealer (re-seller) who traffics in this POS app.

So I write an add-on script for the store manager to run, that will automate this. It consults a config file, from which it gets a list of the files to be downloaded and the local names they are to be given (since the POS app only groks old-style DOS 8.3 names). My script does these steps, basically:
-- Consult the config file to get the list of name and other details of the job (like the name of the FTP site and the user-name to work with.)
-- Writes DOS batch file (which it will soon run) that will, in turn, run FTP
-- Writes a FTP script that FTP will run to connect to the FTP site and get those files.
-- Then runs COMMAND.COM, directing it to run that DOS batch file.
-- The DOS batch file, in turn, runs FTP and gives it the FTP script for its input.

This worked fine for years. Then one day, the client calls to tell me it isn't working right.

Took a while to figure out (all this is done long distance, via verbal phone conversations). Turns out, the wholesaler added several new files to the collection to be downloaded. These new files have longer names than the earlier files, and they have spaces in them. Why? Because the wholesaler has no idea how their customers might be downloading these files, and it never occurs to them that somebody somewhere might have a problems with it!

Turns out that the file names with spaces, which I just write verbatim into the FTP script, don't work. The FTP program treats the spaces as word separators and won't recognize names with spaces.

The resolution? Good thing that I am in a position to modify that add-on module (since I wrote it). I modified it so that it always writes the file names into the FTP script with quotes around them. Fortunately, FTP can work with this. (For the names that don't have spaces in them, it still never hurts to put quotes around them.)

Moral of the story: [b]Don't use file names with spaces, dots, or other odd-ball punctuation. You never can predict how it will be used someday later, or what problems will happen.[b]
#30
Old 10-22-2012, 07:10 PM
Guest
Join Date: Sep 2011
Location: Sunny California
Posts: 14,840
Quote:
Originally Posted by Jragon View Post
I have to say, the programmer in me names everything without spaces because I don't want to have to deal with having to take the special considerations for spaces when writing scripts for myself.

Then when it comes time to actually WRITE the script I get paranoid and make sure to handle spaces anyway.
This!

Create your names simple and clean, especially because you never know who else will be using those names and how they will deal with them.

Write your own scripts and programs to handle odd names, as best you can, because you never know what kinds of names other users (or their programs) will throw at you.
#31
Old 10-22-2012, 08:04 PM
Charter Member
Join Date: Mar 2002
Location: NY but not NYC
Posts: 30,095
So the thread started with a user asking a question about procedures for users. But a bunch of people say that the answer is no because of insane programmer-side technicalities which users will never encounter or care about on systems they will never need to deal with.

Users: USE SPACES IF YOU LIKE THEM

Programmers: USERS AREN'T PROGRAMMERS

I don't care about your issues. My system is vastly superior for my needs while working on my computers. I spent years working on software and I've seen the other side. All the more reason I want you to stay the hell away from what I do at home.
#32
Old 10-22-2012, 08:13 PM
Guest
Join Date: Sep 2011
Location: Sunny California
Posts: 14,840
Fine. Your computers and your files are yours to do with as you please. Note, the OP didn't say much about what he is doing with his files or how he is using them. He didn't say if he ever e-mails files to anybody else, or if he uploads them somewhere.

Anybody is liable to have problems like this someday. That is, anybody who ever obtains a file from somewhere else, or who sends a file to somewhere else. If you never share files with anybody, and only use your own (or other well-known) software to deal with your own files, fine. That's nobody else's problem.

If you EVER have a problem with spaces in file names, because you got a file from somebody else with spaces and your programs don't deal with them, or if you ever send a file-with-spaces to somebody else and the software they use doesn't deal with them --

Well, don't come back whining to the Straight Dopers about it.

Exapno Mapcase, really, what's your beef here? OP asked. Somebody answered.
#33
Old 10-22-2012, 08:18 PM
Charter Member
Join Date: Apr 2003
Posts: 25,865
As a non-programmer, though, I prefer not to use spaces in filenames because I often send emails containing the path to a file (e.g., \\servername\folder1$\folder2\filename.ext). If there are no spaces in the filename, the resulting hyperlink will correctly point to the file, but any spaces will break the hyperlink. (I do know that I can use anchor text with the file path, but I like to just display the actual path.
#34
Old 10-22-2012, 08:24 PM
Guest
Join Date: Aug 2009
Location: Chicago, IL
Posts: 2,521
Quote:
Originally Posted by Exapno Mapcase View Post
So the thread started with a user asking a question about procedures for users. But a bunch of people say that the answer is no because of insane programmer-side technicalities which users will never encounter or care about on systems they will never need to deal with.

Users: USE SPACES IF YOU LIKE THEM

Programmers: USERS AREN'T PROGRAMMERS

I don't care about your issues. My system is vastly superior for my needs while working on my computers. I spent years working on software and I've seen the other side. All the more reason I want you to stay the hell away from what I do at home.
I don't think I've ever agreed with Exapno Mapcase more before.

It's like a mechanic arguing that automakers should only equip cars with manual transmissions because they're easier to fix.
#35
Old 10-22-2012, 08:49 PM
Guest
Join Date: Jan 2003
Location: 7-Eleven
Posts: 6,262
Quote:
Originally Posted by Exapno Mapcase View Post
I'm trying and trying and I cannot imagine any universe in which underscores would be preferred by anyone.
For technical people the underscore has been used extensively when naming all of the entities and objects associated with programming(field names, routine names, program names, script names, etc.), including file names.

I use underscores extensively in file names, sometimes due to habit and sometimes because it is more readable with a separator. I never use spaces in an identifier (like a file name) but will always use them in a description.
#36
Old 10-22-2012, 09:00 PM
Guest
Join Date: Jan 2003
Location: 7-Eleven
Posts: 6,262
Quote:
Originally Posted by typoink View Post
I don't think I've ever agreed with Exapno Mapcase more before.

It's like a mechanic arguing that automakers should only equip cars with manual transmissions because they're easier to fix.
I strongly disagree.

A space can be interpreted as a separator or as data depending on the context.

This introduces multiple problems when used in a file name:
1 - Software written with the understanding that a space is a separator (which is a perfectly valid choice to make) will not operator properly on a file name with a space.

2 - Even when the software is capable of handling spaces in file names, it can be ambiguous depending on the context. For example, if I email a list of file names that contain spaces, how does the receiver know for sure how to interpret spaces? You might think it's obvious because there would be an extension, but not all systems require extensions and not all extensions are known.
#37
Old 10-22-2012, 09:33 PM
Guest
Join Date: Dec 1999
Location: Texas
Posts: 6,658
Quote:
Originally Posted by Senegoid View Post
Took a while to figure out (all this is done long distance, via verbal phone conversations). Turns out, the wholesaler added several new files to the collection to be downloaded. These new files have longer names than the earlier files, and they have spaces in them. Why? Because the wholesaler has no idea how their customers might be downloading these files, and it never occurs to them that somebody somewhere might have a problems with it!

Turns out that the file names with spaces, which I just write verbatim into the FTP script, don't work. The FTP program treats the spaces as word separators and won't recognize names with spaces.

The resolution? Good thing that I am in a position to modify that add-on module (since I wrote it).
My interpretation of this story is that your script had a bug, which you were called in to fix, and you seem indignant that some of the users had the audacity to use perfectly valid features of their OS in naming files.
#38
Old 10-22-2012, 09:47 PM
Guest
Join Date: Mar 2007
Location: Miskatonic University
Posts: 10,310
It's moot for Windows users anyway, almost every file is stored under <Drive>:\Users\<User>\Documents and Settings\*

Almost every program is under

<Drive>:\Program Files\*

Or Program Files (x86) if you're on a 64-bit install. Anybody on Windows who does not handle spaces in filenames is absolutely begging for inevitable trouble, even with relative file paths. You have pretty much no excuse when programming for Windows when integral, common OS file paths contain spaces.

ETA: Sorry, it looks like the structure is

\Users\My Documents
\Users\My Pictures

etc, for some reason I thought all of those were under the group folder "Documents and Settings". The point still stands though since those have spaces.

Last edited by Jragon; 10-22-2012 at 09:52 PM.
#39
Old 10-22-2012, 09:47 PM
Charter Member
Join Date: Oct 1999
Location: Sturgeon Bay, WI USA
Posts: 20,408
Quote:
Originally Posted by CurtC View Post
My interpretation of this story is that your script had a bug, which you were called in to fix, and you seem indignant that some of the users had the audacity to use perfectly valid features of their OS in naming files.
But it wasn't a bug when originally written. The specs changed, which made a bug where there wasn't one before.

Not all changes can be anticipated far in advance.
#40
Old 10-22-2012, 10:00 PM
Guest
Join Date: Mar 2007
Location: Miskatonic University
Posts: 10,310
Quote:
Originally Posted by Jragon View Post
ETA: Sorry, it looks like the structure is

\Users\My Documents
\Users\My Pictures

etc, for some reason I thought all of those were under the group folder "Documents and Settings". The point still stands though since those have spaces.


That's \<User>\My Documents and so on. That one wasn't a case of me misremembering the path, that was stupid fingers, apologies. The point STILL holds.
#41
Old 10-23-2012, 12:14 AM
Member
Join Date: Aug 2002
Location: Deep Space
Posts: 43,458
Quote:
Originally Posted by RaftPeople View Post
For technical people the underscore has been used extensively when naming all of the entities and objects associated with programming(field names, routine names, program names, script names, etc.), including file names.

I use underscores extensively in file names, sometimes due to habit and sometimes because it is more readable with a separator. I never use spaces in an identifier (like a file name) but will always use them in a description.
In many fonts it may be hard to distinguish a space in a file name from two adjacent characters (at least for my eyes) - if you use underscores you'll never have this problem. This happened to me today, not for file names but for another name.
#42
Old 10-23-2012, 12:24 AM
Guest
Join Date: Oct 2012
Location: Pennsylvania, USA
Posts: 90
I know when I'm using terminal on Linux I use a backslash (\) followed by a space to signify a space is there. For example cd ./.wine/drive_c/Program\ Files/

It's not that big of a deal even when using a terminal, however I do try and avoid spaces and prefer an underscore.

Last edited by C6541; 10-23-2012 at 12:25 AM.
#43
Old 10-23-2012, 01:23 AM
Guest
Join Date: Dec 2009
Location: The Land of Smiles
Posts: 16,419
Quote:
Originally Posted by C6541 View Post
I know when I'm using terminal on Linux I use a backslash (\) followed by a space to signify a space is there. For example cd ./.wine/drive_c/Program\ Files/

It's not that big of a deal even when using a terminal, however I do try and avoid spaces and prefer an underscore.
When I'm typing a single filename on a Linux terminal, I use the shell's filename-completion feature and usually need neither type nor escape any special character myself.

In other contexts, creating a batch of filenames with the necessary escapements is much less convenient.
#44
Old 10-23-2012, 02:26 AM
Guest
Join Date: Jul 2002
Location: UK
Posts: 4,930
Quote:
Originally Posted by septimus View Post
(* - I write "was" rather than "is", because in some perverse race-to-the-bottom, the Linux user interface is evolving to emulate the Windows "philosophy" as closely as possible. )
I disagree. While graphical interfaces for Linux (KDE, Gnome etc) are becoming visually somewhat like the Windows/Apple default (well, prior to Windows 8), the fact is these GUI interfaces are considerably more flexible and complete in functionality.

For example, both Gnome and KDE use proper file typing, rather than relying on a 3 character file extension for file ID. They don't hide characters (the aforementioned hide known file extensions). I find them complete in ways that Windows interfaces still dream of.

As for writing scripts to handle filenames with spaces - my rule is Quote Data. If I get a file list from somewhere (a directory list query, say) and I am passing those names to a new command, then I use quoting so I know where a file name ends and a new one begins, and not rely on the shell. Always remember little Bobby Tables, and also, Bobby isn't just for SQL, he's for any input stream.

As for NTFS file name limits, the kicker is when you move a nice big file tree with really long names (a parts maintenance records system for a power station, as I recall) from one server to another, and the new shared directory is deeper on the disk than the source. The files copy (as the 256 char limit is never breached), but cannot be accessed on the new server as they are too deep to be referenced

Si
#45
Old 10-23-2012, 02:42 AM
Guest
Join Date: Sep 2011
Location: Sunny California
Posts: 14,840
Quote:
Originally Posted by septimus View Post
When I'm typing a single filename on a Linux terminal, I use the shell's filename-completion feature and usually need neither type nor escape any special character myself.

In other contexts, creating a batch of filenames with the necessary escapements is much less convenient.
These sorts of things.

Typing commands, whether to the command shell or to FTP or any other command line interface, gets to be a PITA if you need to deal with files with spaces in them (and sometimes other unusual punctuation). Building programs or scripts or other automated processes to do it, and get it right with odd names, can be a PITA. Imaging typing DIR /B > XXX.BAT to get a simple list of file names, which will then be input to some process that creates a batch file with those names. Getting the names properly quoted is a PITA.

There were opposing opinions in posts above, as to whether my script (downloading files with FTP) suffered from a bug, or suffered from a change in the specs. You could take either attitude. But the fact remains, either way, it's a PITA.

There's vast amounts of software out there, in particular all those little quickie simple-minded scripts that people write, that would not deal with odd names, and would be not-so-simple to make them deal with odd names. We've had threads here where people ask how to write a script to process a list of files, and have gotten many quick and easy suggestions. Some of those would not be so easy if someone had to deal with truly arbitrary names that might contain spaces.

Odd names work if all you do is point-and-click on the names in some list in a GUI, like in a Windows Explorer window. And maybe they work if your CLI can do auto-expansion, as suggested above. (Does it quote or escape the spaces as needed? I've never tried it.)

If you create files with spaces, you're making very limiting assumptions about how those names will be used. If all you ever do if point-and-click, that's fine. If you use file names in any other way, you're just asking for trouble sooner or later.

If you don't like underscores, you also have the CamelCaseOptionForLongFileNames.
#46
Old 10-23-2012, 02:44 AM
Charter Member
Join Date: Oct 2000
Location: Twitter: @MeasureMeasure
Posts: 13,419
Quote:
Originally Posted by Dewey Finn View Post
As a non-programmer, though, I prefer not to use spaces in filenames because I often send emails containing the path to a file (e.g., \\servername\folder1$\folder2\filename.ext). If there are no spaces in the filename, the resulting hyperlink will correctly point to the file, but any spaces will break the hyperlink. (I do know that I can use anchor text with the file path, but I like to just display the actual path.
...or if I'm referring to a file in the middle of a paragraph or making a hand written list of files, it's easier to decipher MyFinance2012.txt than a my finance 2012.txt file name.

Last edited by Measure for Measure; 10-23-2012 at 02:46 AM.
#47
Old 10-23-2012, 02:46 AM
Charter Member
Join Date: Feb 2003
Location: Chicagoland(West Burbs)
Posts: 767
I love underscores

I_Know_Nothing
#48
Old 10-23-2012, 02:58 AM
Guest
Join Date: Sep 2011
Location: Sunny California
Posts: 14,840
Quote:
Originally Posted by si_blakely View Post
As for writing scripts to handle filenames with spaces - my rule is Quote Data. If I get a file list from somewhere (a directory list query, say) and I am passing those names to a new command, then I use quoting so I know where a file name ends and a new one begins, and not rely on the shell. Always remember little Bobby Tables, and also, Bobby isn't just for SQL, he's for any input stream.

As for NTFS file name limits, the kicker is when you move a nice big file tree with really long names (a parts maintenance records system for a power station, as I recall) from one server to another, and the new shared directory is deeper on the disk than the source. The files copy (as the 256 char limit is never breached), but cannot be accessed on the new server as they are too deep to be referenced

Si
Yes, it seems one must always bear in mind to quote file names (and other similar data). But there are any number of apps out there, including shells and other CLI's, and it's a crap-shoot which of them you can count on to parse quoted names correctly.

My example was FTP. I never knew that FTP could accept quoted files names. I had never had occasion before to try it or even think about it. When the problem arose, FTP just quietly died. (Well, maybe there were error messages but they weren't getting captured anywhere.) It took a while to figure out WTF was happening. Then I just tried quoting the names and found out they work. But there's never a general assurance that will always happen.

Spaces have been used as word or token separators in computer command syntax since the days of Charles Babbage. Modern parsers have additional syntax to deal with spaces in names, but it's almost always messier, involving typing quotes or escape characters around names. PITA. We need to have some universally agreed-upon character (like a comma maybe?) that can always be used as a separator, and can NEVER be used in a file name.

Wait a minute. We've always had such a universally agreed upon separator, and it was always the blank space character. Then some genius from another reality decided to allow file names to have spaces, and that broke everything, and has been a PITA ever since.

It wasn't Microsoft by the way. The first I ever saw file names with spaces was in the Apple II computer in 1980, before the IBM PC was ever invented.
#49
Old 10-23-2012, 03:21 AM
Guest
Join Date: Apr 2000
Location: Missoula, Montana, USA
Posts: 20,515
Quote:
Originally Posted by septimus View Post
(* - I write "was" rather than "is", because in some perverse race-to-the-bottom, the Linux user interface is evolving to emulate the Windows "philosophy" as closely as possible. )
As long as Linux has ratpoison, this complaint is invalid.

In a larger sense: This is only a problem for people who refuse to stop using the defaults a few of the big 'mass-market' distros pack in, cannot use (or appreciate) a command line, and don't know about package management systems.

Last edited by Derleth; 10-23-2012 at 03:22 AM.
#50
Old 10-23-2012, 06:53 AM
Guest
Join Date: Nov 2004
Location: Harrogate, UK
Posts: 138
Quote:
Originally Posted by Senegoid View Post
These sorts of things.

Typing commands, whether to the command shell or to FTP or any other command line interface, gets to be a PITA if you need to deal with files with spaces in them (and sometimes other unusual punctuation). Building programs or scripts or other automated processes to do it, and get it right with odd names, can be a PITA. Imaging typing DIR /B > XXX.BAT to get a simple list of file names, which will then be input to some process that creates a batch file with those names. Getting the names properly quoted is a PITA.

There were opposing opinions in posts above, as to whether my script (downloading files with FTP) suffered from a bug, or suffered from a change in the specs. You could take either attitude. But the fact remains, either way, it's a PITA.

There's vast amounts of software out there, in particular all those little quickie simple-minded scripts that people write, that would not deal with odd names, and would be not-so-simple to make them deal with odd names. We've had threads here where people ask how to write a script to process a list of files, and have gotten many quick and easy suggestions. Some of those would not be so easy if someone had to deal with truly arbitrary names that might contain spaces.

...

If you create files with spaces, you're making very limiting assumptions about how those names will be used. If all you ever do if point-and-click, that's fine. If you use file names in any other way, you're just asking for trouble sooner or later.

If you don't like underscores, you also have the CamelCaseOptionForLongFileNames.
Oh, come on! After being bitten by that a couple of times, you write another simple little script so that your old DIR /B > XXX.BAT becomes DIR /B | QUOTIFY > XXX.BAT. Always quoting the path will get you out of (that kind of) trouble 99% of the time (Unless you have an O/S which accepts newlines within filenames - in a world where Befunge exists, that level of evil wouldn't surprise me)

If you create filenames with spaces, be prepared to mitigate for programmers making the limiting assumption that a user won't use all of the features of their filesystem. Most people use those extra features (long and mixed case file names, punctuation, spaces) in a fairly predictable way - to enhance readability - the text elements remain the differentiation point. So long as you don't create filenames that only differ in their spacing (ie both "My File.txt" and "MyFile.txt" or a truly pathological filename with multiple consecutive spaces), then all that is needed for that mitigation is a preprocessing step that copies and renames your files so that the readability scaffolding is removed.

What will really make your computer blow up is creating Program.exe in the root of your C: drive. This is related to the way the Windows command line handles unquoted paths that contain spaces (it only actually opens c:\program files after trying to run "c:\program" files - exe, bat and com can all be run without extensions)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:17 AM.

Send questions for Cecil Adams to: [email protected]

Send comments about this website to:

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Copyright 2018 STM Reader, LLC.

Copyright © 2017
Best Topics: serenity reavers pseudoephedrine substitute sultry means dumb usernames she's dead jim martin arriola mensa lsat 3.4 liter engine period frequent urination kerbal reentry greenies amphetamines scary doctors names how to arouse a woman while sleeping barnes and nobles buyback diamond tipped drill bit will fedex leave a package at my door how to cite a transcript greta van susteren face surgery drawn together nipple ring-ring goes to foster care just married car paint returned for additional postage where to sell used fur coats king crab vs snow crab taste