In an introductory GIS course, it was insisted that all spaces within file and folder names be replaced with underscores.
Why is this taught?
Is there a clear benefit of doing so?
One reason is because spaces carry special meaning in several programming/scripting languages.
Making a habit of naming files and folders with underscores is a good practice because then the " " (spaces) will not be treated as a new-line by some languages.
Example - A folder called "GIS Data" is a bad folder name. This is because if I try to access it with a script or some programming language I have to treat the spaces with special care.
If I don't tell it that the spaces are indeed spaces and not new-lines, then it will try to access "GIS" and "Data" as separate folders, but they are not.
In Unix bash from the command line I can use ls command to list the files and folders in a given directory.
I now have to either use backslashes '\' or quotes '' to prevent the spaces being treated as newlines!
The above two commands now treat the spaces as spaces.
Several ArcGIS geoprocessing tools do not like spaces in file or folder names in ANY part of the path to the data source. They will usually just fail with some kind of generic Error 99999.
There are some geoprocessing tools that will fail if there are spaces in file names. Thus, it's best to avoid them all together.
Simply put - it's because spaces in command lines are treated at delimiters. So:
won't work on most operating system command lines without adding quotes:
Many GIS tools are command-line based so its just simpler to use under-scores if you're in an environment where the command-line is common. If you're solely a windows user you can probably get away with just leaving spaces in.