- Go to Windows Explorer, and create a folder/directory named
%systemdrive%
,%windir%
, or any other existing variable. - Open a command prompt, and go to the folder you just created.
You can't, because there are percent (%
) symbols in the folder name, confusing the command prompt, because the percent symbol is used for existing variables.
Escaping the percent (%
) symbol with two percent symbols (%%
) does not work, so DavidPostill's answer is wrong:
So, in Windows Explorer, why can we create a folder or file with the percent (%
) symbol, if the percent symbol is used for existing variables?
Best Answer
Why can we create a folder/file with the percent symbol?
The
%
character is not a reserved character in a file name.The reserved characters for naming files, paths and namespaces are:
Source Naming Files, Paths, and Namespaces
The percent symbol is reserved for variables
The above is not true. Everything works just as you would expect.
Example using
%test%
:Example using
%systemdrive%
:Escaping Percents
The
%
character has a special meaning for command line parameters andFOR
parameters.To treat a percent as a regular character, double it:
Source syntax
Further Reading