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?

  • 3
    The advice should not be limited to spaces! For insight, consider that parts of ArcGIS contain code going back to the 1980's (if not earlier). Back then there were severe limitations on directory and file names: the software assumed names were short (usually 13 characters or less), contained no special characters other than spaces, and did not begin with a numeric digit. (Even this description isn't exactly right, but it's close.) People still run into mysterious problems traceable to this old code. – whuber May 3 '12 at 20:28
  • @whuber is bang on. It's not just spaces though, hyphens, -, also cause trouble because sometimes they're okay and sometimes they're not. See an arcgisscripting method for sanitizing a filename? – matt wilkie May 9 '12 at 19:02

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.


There are some geoprocessing tools that will fail if there are spaces in file names. Thus, it's best to avoid them all together.

  • 3
    Within Esri software, coverages and raster files never tolerated spaces in the names. Placing data sets on a Windows desktop was/is problematic because the folder is actually based in "Documents and Settings" (thus introducing spaces into the whole path name). Shapefiles are much more forgiving and spaces are possible, and I believe feature classes can now have a space and not crash, but old habits die hard. I agree with Jeff Berry - best to avoid them. – dianamaps May 3 '12 at 17:38

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.