55 Votes

Why are certain Characters not allowed in File Names?

Question by Mopsi99 | Last update on 2021-05-13 | Created on 2017-05-15

When trying to rename a file and trying to write for example a question mark, an exclamation mark, a quote, an asterisk, a colon, a greater than or a less than sign into the name, I get the following error message:

A file name can't contain any of the following characters: \ / : * ? " < > |

Accordingly, the filename is not changed, the entered character is not taken over to the new name. But why is it so? Why can I not use arbitrary characters for my file names?

PS: I am using the operating system Windows. I do not know whether the same applies for Linux or Apple Mac.

10Best Answer10 Votes

Some characters have a special meaning for the operating system and therefore they cannot appear in file names.

Let us take the backslash \ as an example. In Windows, this character is used as a delimiter for separating folders from each other. For instance "C:\Folder\Folder\File.txt". If backslashes were allowed in filenames, we could not say whether "Fi\le.txt" is the name of a file or whether it is the file "le.txt" located in the folder "Fi".

The same applies to the other characters you have mentioned. All of them have a special syntactical meaning within path specifications and for excluding ambiguities, they cannot be allowed to be used within filenames.

By the way, the characters not allowed can be different from operating system to operating system, depending on which characters have a special meaning on the corresponding system.
Last update on 2021-05-13 | Created on 2017-05-16

ReplyPositive Negative

Related Topics

Rename File to its Folder Name

Tutorial | 0 Comments

PHP: File Download Script

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.