DavidPostill's answer is great, but may confuse newcomers a little. I'll try to rephrase.
% is not a reserved character.
It is an character with special meaning to the command shell (aka cmd.exe and command.com)
The difference is:
- you cannot use reserved characters at all (but see below)
- you may be able to use special and escape characters - just not by typing them as-is
In other words, you can create a file or folder containing % in their name. You can do it directly using windows explorer because % has no special meaning there. There was no intention to prevent you from creating such files at command prompt either, but because % has a special meaning there, you need to use syntax outlined below to create such files.
BAT-files
If you are writing a batch file (*.bat, *.cmd), which get executed by command shell (aka the command prompt application), to use % literally (such as to create a file with % in the name, and not to substitute a variable or parameter) you need to type %% instead.
For example,
- command
echo %windir% produces output: c:\windows
- however, command
echo %%windir%% produces output: %windir%
- and so on: command
echo %%%%windir%%%% produces output: %%windir%%
So if you save following line as test.bat and run it, it will create a directory named %test% complete with percent signs:
md %%test%%
If there is no variable named test, this next command is equivalent to the last one - it also creates a directory %test%:
md %test%
...but please never do it like that since your command will not behave the way you wanted once someone creates a variable with that name
If you intend to use command for in a BAT-file, you also need to double % so that it would have special meaning to for command instead of for the command shell itself:
for %%i in (*.*) do echo %%i
This will produce a list of files in current directory (that is, %%i has special meaning), and I'm not sure how to make it produce literal %%i without resorting to %p% workaround described in the next section (%%%%i does not work here).
% is not the only character with special meaning at command prompt. Others include ^, <, >, |, (, ), &, !, ". Most of those (excluding ") can be escaped - that is, prefixed with an escape-character ^ so that a literal character is inserted, suppressing its special meaning. Those also lose their special function inside doublequoted string, and " is escaped with a backslash: \". Some carets (^) may need to be doubled inside doublequote-enclosed string and where delayed variable substitution takes place (! special meaning).
Command prompt
Unfortunately, when typing commands into command prompt window directly, doubling % character just produces %% i.e. the above approach does not work in that case.
There appears to be a workaround exploiting a quirk in command processing - you can get literal % by typing ^ after %. That approach is not foolproof though: if your filename is enclosed in double quotes, ^ is interpreted literally (and not removed like without quotes)
- command
echo %windir% produces output: c:\windows
- command
echo %^windir% produces output: %windir%
- command
echo "%^windir%" produces output: "%^windir%" (with extra ^ - not what we wanted)
I recommend another workaround instead:
- create a variable like this:
set "p=%"
- use
%p% whereever you need a literal percent sign: echo "%p%windir%p%" will now produce output: "%windir%"
The same workaround can be used to get literal percent sign in for command, however note that unlike BAT-files when keying the for command directly you do not double percent signs.
Filesystem reserved characters
You cannot normally create a file or directory containing following reserved characters in its name: / ? < > \ : * | ", NULL-symbol and characters with codes 1 to 31; also . and space cannot be last characters; and following names are illegal: com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9 con nul prn.
However, some of these restrictions can be bypassed prefixing file path with \\?\ like this: \\?\c:\test...\nul. At least files with reserved names and those ending with space and dot can be manipulated that way.
What's more, NTFS filesystem itself supports several naming subsystems: DOS, Windows and POSIX. It is the Windows subsystem that has all the restrictions above, while POSIX only forbids / and NULL-symbol.
GNU/Linux OS (a superset of POSIX) can thus create (and delete) file/directory names that most normal windows API functions (and therefore windows programs) cannot work with. On Windows XP working with them was possible by installing free "Services For Unix subsystem" (SFU); on Vista and above third-party tools are required for that. I'm not sure if new ubuntu-on-windows10 subsystem can do it.