The Microsoft documentation about
Naming Files, Paths, and Namespaces describes clearly that the directory separator is
\ on Windows and not
/ as on Linux/Mac. The documentation page describes also how the Windows file I/O automatically corrects file/folder strings with
/ to strings with
\ before passing the file/folder strings to the file system (usually NTFS or FAT32).
Applications written natively for Windows like the
Windows commands interpret an argument beginning with
/ as an option. UltraEdit does that also because of supporting multiple options whereby most begin with
/ as that character is not allowed in a file/folder name on Windows which is the reason for the automatic correction by Windows file I/O.
Many applications are nowadays ported from Linux to Windows and use on Windows also the Linux standard for options. Command line options on Linux/Mac begin with
- which is usually not used as first character of a file/folder name. Such applications do not have a problem with an argument string beginning with
/ because of not interpreting such an argument string as a command line option. The argument string is interpreted as file/folder name and is passed later to the Windows file I/O which automatically corrects the wrong directory separator.
It is nevertheless not advisable to use
/ in file/folder strings on Windows as that can result in an unexpected behavior on execution despite the automatic correction by Windows file I/O depending on the application. The
Windows Command Processor cmd is such an application.
Example of wrong execution behavior caused by using
/ instead of
\ in a command prompt window.
Code: Select all
for %I in (%SystemRoot%/*.exe) do @if exist "%I" (echo Existing file: "%I") else echo Missing file: "%I"
This command line executed in a command prompt window with current working directory being not the Windows directory outputs that every executable file found in the Windows directory by the Windows file I/O does not exist for the
Windows Command Processor.
Code: Select all
for %I in (%SystemRoot%\*.exe) do @if exist "%I" (echo Existing file: "%I") else echo Missing file: "%I"
This command line always works and outputs all found executables in the Windows directory as existing file. The difference between the two command lines is just the usage of wrong
/ instead of correct
\ in the wildcard pattern with full path causing
cmd interpreting the found file name wrong as it can be seen on the output file names.
Another example is the command
CD. There is the directory
Downloads in root directory of the current drive. The execution of
cd /Downloads fails with an error message because of
CD interprets
/D as option and the remaining string
ownloads as name of the subdirectory to change to in the current working directory. The execution of
cd \Downloads works and changes the current directory on same drive to the subdirectory
Downloads of the root directory of current drive.
A file/folder string beginning with
/ references on Linux/Mac a file/folder with its absolute name.
/ at the beginning means root of the file system on Linux/Mac. A file/folder string beginning with
\ references on Windows the root directory of the current drive and is therefore a relative path specification as described by Microsoft on the first linked documentation page. Users of Git on Windows should know all those differences in syntax between Windows and Linux/Mac.