If, like most of us, you use Windows, at some point you've probably gotten a notification
that looks like this, telling you that you can't use certain characters in a filename.
But why? I mean, quotes and question marks are common enough in everyday use, so why can't I just
put them in the friggin' file and what the heck is going on? Is Microsoft just trying to play mind games with us, or do they actually have a good reason?
It turns out, these restrictions are due to how the operating system itself reads filenames.
You see, Windows uses certain characters to denote certain actions the operating system
needs to follow when it's working with a file. You're probably familiar with how backslash precedes the name of a subfolder, and as such,
you cannot put a backslash in the filename, since otherwise Windows would confuse the
filename for another folder that isn't even there.
Similarly, you can't use a colon, since Windows understands a colon to denote a drive letter,
which comes at the beginning of a file path to tell Windows what drive to begin looking
for the file on. What about forward slash?
Well, these can still be used to point to certain resources.
Think about how you can have a shortcut on your desktop to a certain web page that uses
forward slashes in the URL. The question mark, ironically, has the potential to cause Windows some confusion as well.
You can actually use it as a wildcard of sorts when you run a search.
For example, if you want to find all the files that match most of a certain filename, you
can throw in a question mark to tell Windows to return a result for any character in that
space where the question mark is. So it follows that you simply can't use it in your filenames.
Oh, and the asterisk is restricted for similar reasons, as if you search for something like
asterisk.png, you'll get all png files in whichever folder you're searching.
Moving on, quotation marks are disallowed because Windows reserves them to indicate
a full path if the path itself has a space in it.
If you bring up a window shortcut, you can see that the path it's pointing to will often
include quotes by default. This is especially useful if you're trying to put modifiers after the path.
For example, if you're trying to force a game to run in a certain sized window, you can
try putting a space after the filename, then hyphen w hyphen r followed by your desired
resolution. These quotes help Windows know that the space after the filename isn't part of the path,
and that you're instead trying to tell Windows to do something else.
And there are other disallowed characters that you may not see unless you're using
the command line instead of the typical Windows GUI.
The greater and less than symbols fall into this category, for example.
For the other characters and uses that we don't have time for today, I'm sure some
of you can discuss those in the comments and help us out. Of course, Windows approach to this isn't always super intuitive, which is why the
frustration stems to begin with. You can still use periods in a filename, even though the last period denotes the beginning
of the extension, which tells Windows what kind of file it is, so that's a little inconsistent.
And why can't you, for example, use a colon later on in the filename as it's typically
just the first one in the path that denotes a drive letter?
Sometimes characters are restricted simply to avoid confusion, and I get this, can be
frustrating, but you can always substitute my personal favorite, the semicolon, right?
So thanks for watching, guys. If you liked this video, give it a thumbs up, hit subscribe, and be sure to hit us up
in the comments section with your suggestions for topics that we should cover in the future.