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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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.
ls GIS Data
ls: GIS: No such file or directory ls: Data: No such file or directory
I now have to either use backslashes '\' or quotes '' to prevent the spaces being treated as newlines!
ls '1 2 3' or ls 1\ 2\ 3
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.
Simply put - it's because spaces in command lines are treated at delimiters. So:
delete C:\directory\file number 1.shp
won't work on most operating system command lines without adding quotes:
delete "C:\directory\file number 1.shp"
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.