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 currentRepresentations of paths by operating system and shell
Japanese and Korean versions of Windows may often display the ' ¥' character or the 'Paths 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 forhttp //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 Ham ...
SharedFolder/Resource
becomes
\\HostName SSL@Port]\SharedFolder\Resource
When viewed remotely, the "SharedFolder" may have a name different from what a program on the server sees when opening "\SharedFolder". Instead, the SharedFolder name consists of an arbitrary name assigned to the folder when defining its "sharing".
Some Microsoft Windows interfaces also accept the "Long UNC":
\\?\UNC\ComputerName\SharedFolder\Resource
Microsoft Windows uses the following types of paths:
* local file system (LFS), such as C:\File
* universal naming convention (UNC), such as \\Server\Volume\File
or /Directory name
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 ...
/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
Shell may refer to:
Architecture and design
* Shell (structure), a thin structure
** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses
** Thin-shell structure
Science Biology
* Seashell, a hard o ...
in Windows XP
Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Windows 2000 for high-end and ...
and Windows Vista
Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, which was released five years before, at the time being the longest time span between successive releases of ...
, explorer.exe
File Explorer, previously known as Windows Explorer, is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface for accessing the file ...
, 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 expression
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or ...
s, 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 officia ...
: 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 string
A string literal or anonymous string is a string value in the source code of a computer program. Modern programming languages commonly use a quoted sequence of characters, formally " bracketed delimiters", as in x = "foo", where "foo" is a strin ...
s, 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 interf ...
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
SCP may refer to:
Organizations Political parties
* Soviet Communist Party, the leading political party in the former Soviet Union
* Syrian Communist Party
* Sudanese Communist Party
* Scottish Christian Party
Companies
* Seattle Computer Produ ...
, rcp and rsync
rsync is a utility for efficiently transferring and synchronizing files between a computer and a storage drive and across networked computers by comparing the modification times and sizes of files. It is commonly found on Unix-like operat ...
) use resource definitions such as:
hostname:/directorypath/resource
or URI Uri may refer to:
Places
* Canton of Uri, a canton in Switzerland
* Úri, a village and commune in Hungary
* Uri, Iran, a village in East Azerbaijan Province
* Uri, Jammu and Kashmir, a town in India
* Uri (island), an island off Malakula Islan ...
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, and ot ...
-style file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
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's u ...
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, Wind ...
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
In computing, a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories. On many computers, directories are known as folders, or drawers, analogous to a workbench or the tr ...
; 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
In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just cur ...
. (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 ev ...
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
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, Windo ...
shell (often called the "terminal" as it typically runs in a terminal window). Note that many other shells available for Windows, such as tcsh
tcsh ( “tee-see-shell”, “tee-shell”, or as “tee see ess aitch”, tcsh) is a Unix shell based on and backward compatible with the C shell (csh).
Shell
It is essentially the C shell with programmable command-line completion, command-l ...
and Windows PowerShell
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-sourc ...
, 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 ope ...
/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 serv ...
-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
In computing, a serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time. This is in contrast to a parallel port, which communicates multiple bits simultaneously in parallel. ...
( 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 switch
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
es.
*note: CD does not work this way:
CD "rive letter
Rive or La Rive may refer to:
Places
* Rive, Piedmont, Italy
* Rive d'Arcano, Friuli-Venezia Giulia, Italy
* Rive Droite, Paris, France
* Rive Gauche, Paris, France
People
* De la Rive, a surname and list of people
* Julie Rivé-King (1854-1937) ...
/Program Files" will only work from the root (rive letter
Rive or La Rive may refer to:
Places
* Rive, Piedmont, Italy
* Rive d'Arcano, Friuli-Venezia Giulia, Italy
* Rive Droite, Paris, France
* Rive Gauche, Paris, France
People
* De la Rive, a surname and list of people
* Julie Rivé-King (1854-1937) ...
\) 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
basename is a standard computer program on Unix and Unix-like operating systems. When basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX Sp ...
* Device file
In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow a ...
* 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 Single U ...
* Distributed file system
A clustered file system is a file system which is shared by being simultaneously mounted on multiple servers. There are several approaches to clustering, most of which do not employ a clustered file system (only direct attached storage for ...
(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 setting.
...
* 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 Identifi ...
(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, API ...
{{DEFAULTSORT:Path (computing)
Computer file systems