Is it a bad idea for a file name to contain space and capital letters?

When naming a file, (for example in OneDrive) is it a bad idea for the name to contain space and capital letters? Is there any potential conflicts it might cause? Should I use hyphen or underscore instead?


Solution 1:

Certain characters and special words aren't allowed and can make a file name or folder name invalid and unacceptable to OneDrive:

  1. Certain characters have special meaning and thus aren't allowed - " * : < > ? / \

  2. On OneDrive with Sharepoint, these aren't allowed - ~ " # % & * : < > ? / \ { | }.

  3. Leading (before the filename) and trailing (after the filename) spaces in file or folder names also aren't allowed. If you're using Office 2010, you can't use "&" in file and folder names.

  4. These names aren't allowed for files or folders: .lock, CON, PRN, AUX, NUL, COM0 - COM9, LPT0 - LPT9, _vti_, desktop.ini; filenames also cannot start with ~$.

  5. "_vti_" cannot appear anywhere in a file name.

Source: Invalid file names and file types in OneDrive and SharePoint.

So, while spaces are certainly allowed in the name, you have to be careful there is no space before or after the name. Both hyphen and underscore are also allowed.

While spaces aren't likely to cause any issues, as others have pointed out, it is easier to type hypens or underscore in a Terminal command. Many advanced users thus tend to avoid spaces and use hyphens or underscores in general. In general though, spaces in names should not cause any issue with MS Office or OneNote.

Solution 2:

This is an excellent question and from my experience, one big factor to consider is whether you will access the same files using command line or not. Consider these two different files names - Name Name and name-name.

Say, you wanted to cd into either of these folders and compare these commands:

  • cd Name\ Name/
  • cd name-name/

Imho, 2nd case is much easier to use when scripting or using shell in general.

Though first case is preferable if you are not going to do anything tech savvy as it feels more natural.

Name conflict (or collision) is a condition when there are two files with identical names irregardless of the characters used.

Also, remember that legacy applications may not support whitespace in file path.