History
dir /w
runs the dir
command with the wide list format option.
This use of slash can still be found in the command interface under Absolute and relative paths
An absolute or full path points to the same location in a file system, regardless of the current working directory. To do that, it must include theRepresentations of paths by operating system and shell
Japanese and Korean versions of Windows may often display the ' ¥' character or the ' ₩' character instead of the directory separator. In such cases the code for a backslash is being drawn as these characters. Very early versions of MS-DOS replaced the backslash with these glyphs on the display to make it possible to display them by programs that only understood 7-bitPaths in programming languages
Programming languages also use paths. E.g.: When a file is opened. Most programming languages use the path representation of the underlying operating system:uxFile = fopen("project/readme.txt", "r")
winFile = fopen("C:\\Program Files\\bin\\config.bat", "r")
This direct access to the operating system paths can hinder the portability of programs. To support portable programs Universal Naming Convention
The Microsoft Windows UNC, short for Universal Naming Convention or Uniform Naming Convention, specifies a common syntax to describe the location of a network resource, such as a shared file, directory, or printer. The UNC syntax for Windows systems has the generic form: \\ComputerName\SharedFolder\Resource Microsoft often refers to this as a "network path". Some Microsoft Windows interfaces also allow or require UNC syntax for WebDAV share access, rather than a URL. The UNC syntax is extended with optional components to denote use of SSL and TCP/IP port number, a WebDAV URL ofhttp //HostNamePort
A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as H ...
SharedFolder/Resource
becomes
\\HostNameC:\File
* universal naming convention (UNC), such as \\Server\Volume\File
or / Directory name/code> (at least in Windows 7 and later)
* "long" device path such as \\?\C:\File
or \\?\UNC\Server\Volume\File
. This path points to the local file namespace and is a similar one that points to the local DOS device namespace. This format is also the "raw" or "uninterpreted" path, since it sends paths straight to the file system without converting to and interpreting names like .
* Windows NT object manager \\??\
-prefixed paths (global DOS namespace).
In versions of Windows prior to Windows XP, only the APIs that accept "long" device paths could accept more than 260 characters.
The shell in Windows XP
Windows XP is a major release of Microsoft's Windows NT operating system. It was release to manufacturing, released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Wind ...
and Windows Vista, explorer.exe, allows path names up to 248 characters long.
Since UNCs start with two backslashes, and the backslash is also used for string escaping and in regular expressions, this can result in extreme cases of leaning toothpick syndrome In computer programming, leaning toothpick syndrome (LTS) is the situation in which a quoted expression becomes unreadable because it contains a large number of escape characters, usually backslashes ("\"), to avoid delimiter collision.
The offici ...
: an escaped string for a regular expression matching a UNC begins with 8 backslashes – \\\\\\\\
– because the string and regular expression both require escaping. This can be simplified by using raw strings, as in C#'s @"\\\\"
or Python's r'\\\\'
, or regular expression literals, as in Perl's qr
.
POSIX pathname definition
Most Unix-like systems use a similar syntax.
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming in ...
allows treating a path beginning with two slashes in an implementation-defined manner,
though in other cases systems must treat multiple slashes as single slashes.POSIX pathname definition
/ref>
Many applications on Unix-like systems (for example, scp, rcp and rsync) use resource definitions such as:
hostname:/directorypath/resource
or URI schemes with the service name (here 'smb'):
smb://hostname/directorypath/resource
Example
Unix style
The following worked example discusses the behavior of a Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
-style file system as it would appear from a terminal or terminal application (command-line window):
Attached to a current working directory (cwd) of:
/users/mark/
One wants to change the current working directory to:
/users/mark/bobapples
At that moment, the relative path for the desired directory
Directory may refer to:
* Directory (computing), or folder, a file system structure in which to store computer files
* Directory (OpenVMS command)
* Directory service, a software application for organizing information about a computer network' ...
can be represented as:
./bobapples
or for short:
bobapples
and the absolute path for the directory as:
/users/mark/bobapples
Given ''bobapples'' as the relative path for the directory wanted, the following may be typed at the command prompt
Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows (Windows NT family and Windows CE family), and ReactOS operating systems. On Windows CE .NET 4.2, ...
to change the current working directory to bobapples:
cd bobapples
Two dots ("") point upwards in the hierarchy
A hierarchy (from Greek: , from , 'president of sacred rites') is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another. Hierarchy is an important ...
, to indicate the parent directory; one dot ("") represents the current directory itself. Both can be components of a complex relative path (e.g., ""), where "" alone or as the first component of such a relative path represents the working directory. (Using "" to refer to a file "" in the current working directory can sometimes usefully distinguish it from a resource "" to be found in a default directory or by other means; for example, to view a specific version of a manual page
A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and ...
instead of the one installed in the system.)
MS-DOS/Microsoft Windows style
Contrary to popular belief, the Windows system API accepts slash, and thus all the above Unix examples should work. But many applications on Windows interpret a slash for other purposes or treat it as an invalid character, and thus require you to enter backslash – notably the cmd.exe shell (often called the "terminal" as it typically runs in a terminal window). Note that many other shells available for Windows, such as tcsh and Windows PowerShell, allow the slash.
In addition "\" does not indicate a single root, but instead the root of the "current disk". Indicating a file on a disk other than the current one requires prefixing a drive letter and colon. No ambiguity ensues, because colon is not a valid character in an MS-DOS filename, and thus one cannot have a file called "A:" in the current directory.
UNC names (any path starting with ) do not support slashes.
The following examples show MS-DOS
MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few o ...
/Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for se ...
-style paths, with backslashes used to match the most common syntax:
A:\Temp\File.txt
This path points to a file with the name , located in the directory , which in turn is located in the root directory of the drive .
C:..\File.txt
This path refers to a file called located in the parent directory of the current directory on drive .
Folder\SubFolder\File.txt
This path denotes a file called located in directory which in turn is located in directory which is located in the current directory of the current drive (since this example gives no drive-specification).
File.txt
This rather simple path points to a file named File.txt
located in the current directory (since the path lacks a directory-specification) on the current drive (since no drive specification is present).
\\.\COM1
This path refers to the first serial port ( COM1).
C:\>more < C:/Windows/system.ini
; for 16-bit app support
86Enhwoafont=dosapp.fon
EGA80WOA.FON=EGA80WOA.FON
EGA40WOA.FON=EGA40WOA.FON
CGA80WOA.FON=CGA80WOA.FON
CGA40WOA.FON=CGA40WOA.FON
...
This example uses a path containing slashes as directory separator. The command redirects the content of the file to the more
command.
E:\>dir "/Folder/SubFolder/" /Q
Volume in drive E is Data
Volume Serial Number is 07BE-0B10
Directory of E:\Folder\SubFolder
18 October 2008 08:15 AM DOMAIN\user .
18 October 2008 08:15 AM DOMAIN\user ..
18 October 2008 08:15 AM DOMAIN\user File.txt
1 File(s) 8 bytes
2 Dir(s) 19,063,000 bytes free
A path containing forward slashes often needs to be surrounded by double quotes to disambiguate it from command line switches.
*note: CD does not work this way:
CD " rive letter/Program Files" will only work from the root ( rive letter\) directory. This appears to treat all forward slashes the same as .\.
*exception: Use the /D switch to change current drive in addition to changing current directory for a drive.
For example:
CD "C:.\Program Files"
works the same as
CD "C:/Program Files"
Also, from a root folder:
CD "C:.\Program Files.\Internet Explorer"
would be treated the same as
CD "C:/Program Files/Internet Explorer"
If there is no relative path to the directory name specified with forward slashes you will get the following error:
The system cannot find the path specified.
For setting environment variables, it is sometimes necessary to provide a path that does not contain spaces in it, for instance defined as "C:\Program Files\Java..." can cause scripts to halt when they encounter the space in the path name. To get the eight-character name Windows assigns to any directory for substitution in environment variables, use the directory listing command with the /x option one level up from the target directory. For instance, the following will get you the eight character name for all directories directly under root:
C:\>dir /x
See also
* Filename
A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose different restrictions on filename lengths.
A filename may (depending on the file system) include:
* name &ndas ...
* basename
* Device file
* dirname
dirname is a standard computer program on Unix and Unix-like operating systems. When dirname is given a pathname, it will delete any suffix beginning with the last slash ('/') character and return the result. dirname is described in the Sing ...
* Distributed file system (DFS)
* Filesystem Hierarchy Standard
The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well. It is maintained b ...
(FHS)
* Fully qualified file name
* PATH (variable)
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH set ...
* Uniform Resource Locator
A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identif ...
(URL)
References
External links
Path Definition
- The Linux Information Project (LINFO)
Naming Files, Paths, and Namespaces
- Local File Systems : Windows : Microsoft Docs
Microsoft Docs is the library of technical documentation for end users, developers, and IT professionals who work with Microsoft products. The Microsoft Docs website provides technical specifications, conceptual articles, tutorials, guides, AP ...
{{DEFAULTSORT:Path (computing)
Computer file systems