File and directory paths follow certain conventions. These include the possible use of a drive letter followed by a colon (:
), the use of backslash (\\
) as the path separator, and the distinction between relative and absolute paths.
Forward slash (/
) often works when used instead of (\\
) but not always; it is normally used to mark switches (options). Using forward slash can lead to various obscure behaviors, and is best avoided.
Special device names include NUL
, CON
, PRN
, AUX
, COM1
, ..., COM9
, LPT1
, ..., LPT9
; these can be redirected to.
Examples:
attrib C:\\Windows\\System32\\notepad.exe
attrib \\Windows\\System32\\notepad.exe
C:
, and if the file exists, as it should. This is an absolute path without a drive letter.cd /d C:\\Windows & attrib System32\\notepad.exe
attrib
is a relative path.cd /d C:\\Windows\\System32 & attrib C:notepad.exe
Succeeds if the file exists. The path given to attrib
is a one despite containing a drive letter: there would have to be C:\\notepad.exe
with a backslash for that to be an absolute path.
relative
cd /d C:\\Windows & attrib .\\System32\\notepad.exe
attrib .
cd /d C:\\Windows & attrib .\\System32\\\\\\notepad.exe
cd /d C:\\Windows & attrib .\\System32
cd /d C:\\Windows & attrib .\\System32\\
cd C:\\Windows\\System32\\
cd ..
attrib C:\\Windows\\System32\\..\\..\\Windows\\System32
attrib \\\\myserver\\myvolume
cd \\\\myserver\\myvolume
pushd \\\\myserver\\folder
attrib C:/Windows/System32/notepad.exe
cmd.exe
. Uses forward slashes.