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?

  • All of your question could pertain to iPhone / iPad / Mac or even Windows using iCloud. What OS is your computer?
    – bmike
    Feb 5, 2021 at 22:00
  • @bmike macOS Big Sur 11.1
    – Katrine
    Feb 6, 2021 at 10:19

2 Answers 2


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.

  • Hi. Thank you for the answer:-) What exactly is a terminal command, and what kind of trouble might space in the file name cause? Could you potentially lose a file because of a "bad" filename?
    – Katrine
    Feb 6, 2021 at 9:35
  • @Katrine Before mouse and graphics, we had to type commands to do something on computers. This is what we refer to as the terminal commands. Many advanced users still use such commands to do some automated processing on their files. Most MS Office users rarely use such Terminal commands, so you can ignore it. But no, you cannot lose a OneNote file because of spaces in its name. And it doesn't really cause any trouble even in Terminal commands (I will update my answer - I was thinking of the really old days when spaces in a filename did occassionally cause some issue.)
    – sfxedit
    Feb 7, 2021 at 10:13

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.

  • What does „two files with identical names irregardless of the characters used.“ mean, especially the irregardless part?
    – nohillside
    Feb 5, 2021 at 21:22
  • To paraphrase, you can have a file name conflict with any kind of characters. It does not matter what those characters are (letters, numbers, underscore, spaces, etc.). What matters if the file names are the same or not. Beware of a special case with a trailing space - Filename and Filename are two different files to the OS. Feb 5, 2021 at 21:28
  • Isn‘t „all characters are the same“ the same as „identical“?
    – nohillside
    Feb 5, 2021 at 23:28
  • 1
    No, characters which look visually can have different character codes. OS will use those code to compare filenames. Saying "the same" can be ambiguous as-in, interpreted to be visually similar. Identical implies that all of their parameters (character codes included) are equal. Feb 6, 2021 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .