Path (computing)
Encyclopedia
A path, the general form of a file
Computer file
A computer file is a block of arbitrary information, or resource for storing information, which is available to a computer program and is usually based on some kind of durable storage. A file is durable in the sense that it remains available for programs to use after the current program has finished...

name or of a directory
Directory (file systems)
In computing, a folder, directory, catalog, or drawer, is a virtual container originally derived from an earlier Object-oriented programming concept by the same name within a digital file system, in which groups of computer files and other folders can be kept and organized.A typical file system may...

 name, specifies a unique location in a file system
File system
A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...

. A path points to a file system location by following the directory tree hierarchy expressed in a string
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

 of characters
Character (computing)
In computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to a grapheme, grapheme-like unit, or symbol, such as in an alphabet or syllabary in the written form of a natural language....

 in which path components, separated by a delimiting character, represent each directory. The delimiting character is most commonly the slash
Slash (punctuation)
The slash is a sign used as a punctuation mark and for various other purposes. It is now often called a forward slash , and many other alternative names.-History:...

 ("/"), the backslash
Backslash
The backslash is a typographical mark used mainly in computing. It was first introduced to computers in 1960 by Bob Bemer. Sometimes called a reverse solidus or a slosh, it is the mirror image of the common slash....

 character ("\"), or colon (":"), though some operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s may use a different delimiter
Delimiter
A delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values.Delimiters represent...

. Paths are used extensively in computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

 to represent the directory/file relationships common in modern operating systems, and are essential in the construction of Uniform Resource Locator
Uniform Resource Locator
In computing, a uniform resource locator or universal resource locator is a specific character string that constitutes a reference to an Internet resource....

s (URLs).

Systems can use either absolute or relative paths. A full path or absolute path is a path that points to the same location on one file system regardless of the working directory
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. When the process refers to a file using a simple file name or relative path , the reference is interpreted relative to the current working directory of...

 or combined paths. It is usually written in reference to a root directory
Root directory
In computer file systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the root of a tree — the starting point where all branches originate.-Metaphor:...

.

A relative path is a path relative to the working directory
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. When the process refers to a file using a simple file name or relative path , the reference is interpreted relative to the current working directory of...

 of the user or application, so the full absolute path will not have to be given.

Representations of paths by operating system and shell

Operating System Shell Root Directory Directory Separator Parent Directory Examples
Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 OS
Unix shell
Unix shell
A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems...

/ / .. /home/user/docs/Letter.txt
DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

COMMAND.COM
COMMAND.COM
COMMAND.COM is the filename of the default operating system shell for DOS operating systems and the default command line interpreter on Windows 95, Windows 98 and Windows Me...

[drive letter:]\ or
\\[server name]\
/ or \ (note: command.com does not treat / as a directory separator) .. C:\USER\DOCS\LETTER.TXT
A:PICTURE.JPG
\\SERVER01\USER\DOCS\LETTER.TXT
OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

cmd.exe
Cmd.exe
Command Prompt is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems...

[drive letter:]\ / or \ .. C:\user\docs\Letter.txt
A:Picture.jpg
Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

cmd.exe
Cmd.exe
Command Prompt is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems...

[drive letter:]/ or
[drive letter:]\ or or
\\[server name]\
note: for CD command, / treated as relative path (same as [drive letter:].\)
/ or \ (note: for CD command, / treated as relative path (same as .\)) .. C:\user\docs\Letter.txt

A:Picture.jpg

\\Server01\user\docs\Letter.txt
Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

Windows PowerShell
Windows PowerShell
Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework...

[drive name:]/ or [drive name:]\or
\\[server name]\ or

[PSSnapIn name]\[PSProvider name:][:PSDrive root]
/ or \ .. C:\user\docs\Letter.txt

\\Server01\user\docs\Letter.txt

UserDocs:/Letter.txt

Variable:PSVersionTable

Registry::HKEY_LOCAL_MACHINE\SOFTWARE\

Microsoft.PowerShell.Security\Certificate::CurrentUser\
TOPS-20
TOPS-20
The TOPS-20 operating system by Digital Equipment Corporation was the second proprietary OS for the PDP-10 mainframe computer. TOPS-20 began in 1969 as the TENEX operating system of Bolt, Beranek and Newman...

DCL
DIGITAL Command Language
DCL, the DIGITAL Command Language, is the standard command languageadopted by most of the operating systems that were sold by the former Digital Equipment Corporation...

[device name:] . PS:LETTER.TXT,4
RSX-11
RSX-11
RSX-11 is a family of real-time operating systems mainly for PDP-11 computers created by Digital Equipment Corporation , common in the late 1970s and early 1980s. RSX-11D first appeared on the PDP-11/40 in 1972...

DCL
DIGITAL Command Language
DCL, the DIGITAL Command Language, is the standard command languageadopted by most of the operating systems that were sold by the former Digital Equipment Corporation...

[device name:] DR0:[30,12]LETTER.TXT;4
OpenVMS
OpenVMS
OpenVMS , previously known as VAX-11/VMS, VAX/VMS or VMS, is a computer server operating system that runs on VAX, Alpha and Itanium-based families of computers. Contrary to what its name suggests, OpenVMS is not open source software; however, the source listings are available for purchase...

DCL
DIGITAL Command Language
DCL, the DIGITAL Command Language, is the standard command languageadopted by most of the operating systems that were sold by the former Digital Equipment Corporation...

[device name:] or

[NODE["accountname password"]]::[device name]:
. [-] SYS$SYSDEVICE:[USER.DOCS]PHOTO.JPG
GEIN::[.DRAFTS]LETTER.TXT;4
Classic Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

[volume or drive name]: : :: Macintosh HD:Documents:Letter
AmigaOS
AmigaOS
AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000...

Amiga CLI / AmigaShell [drive, volume, device or assign name]: / / Workbench:Utilities/MultiView

DF0:S/Startup-Sequence

S:Startup-Sequence

TCP:en.wikipedia.com/80
RISC OS
RISC OS
RISC OS is a computer operating system originally developed by Acorn Computers Ltd in Cambridge, England for their range of desktop computers, based on their own ARM architecture. First released in 1987, under the name Arthur, the subsequent iteration was renamed as in 1988...

Task window [fs type[#option]:][:drive number or disc name.]$
note: &, % and @ can also be used to reference the root of the current user, the library and the current (working) directory respectively.
. ^ ADFS::MyDrive.$.Documents.Letter

Net#MainServer::DataDrive.$.Main.sy10823

LanMan::WindowsC.$.Pictures.Japan/gif

NFS:&.!Choices

ADFS:%.IfThere



When filesystems with filename extensions are mounted, '.' characters are changed to '/', as in the Japan/gif example above.
Symbian OS File manager \ \ \user\docs\Letter.txt
Domain/OS
Domain/OS
Domain/OS is the operating system used by the Apollo/Domain line of workstations manufactured by Apollo Computer, Inc. during the late 1980s, as the successor to the one previously used, AEGIS. It was one of the early distributed operating systems...

Shell // /
MenuetOS
MenuetOS
MenuetOS is an operating system with a monolithic preemptive, real-time kernel, including video drivers, all written in FASM assembly language, for 64-bit and 32-bit x86 architecture computers, by Ville M. Turjanmaa...

CMD / /
Stratus VOS
Stratus VOS
VOS is a proprietary operating system running on Stratus Technologies fault-tolerant computer systems. VOS is available on Stratus's ftServer and Continuum platforms...

VOS command-line interpreter %[system_name]#[module_name]> > <
NonStop Kernel TACL Tandem Advanced Command Language No root . No parent directory \NODE.$DISK.SUBVOL.FILE
\NODE.$DEVICE

\NODE.$DEVICE.#SUBDEV.QUALIFIER
CP/M
CP/M
CP/M was a mass-market operating system created for Intel 8080/85 based microcomputers by Gary Kildall of Digital Research, Inc...

CCP
CCP
- Politics :* Canadian Conservative Party, majority government* Chinese Communist Party, the ruling political party in the People's Republic of China* Confederación Campesina del Perú, a peasant organization in Peru- Other :...

[drive letter:] no subdirectories no parent A:LETTER.TXT


Japanese and Korean versions of Windows may often display the '¥
¥
¥ is a currency sign used by the Japanese yen and the Chinese yuan currencies. The symbol resembles a Latin letter Y with a double stroke. The base unit of both currencies shared the same Chinese character pronounced yuán in Mandarin Chinese and en in Standard Japanese...

' 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-bit ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 (other characters such as the square brackets were replaced as well, see ISO 646, Windows Codepage 932 (Japanese Shift JIS), and Codepage 949 (Korean)). This predates the addition of paths in MS-DOS 2 and is a good indication that Microsoft did not intend the backslash to be the path separator, as a normal slash would display correctly. Although even the first version of Windows supported the 8-bit ISO-8859-1 character set which has the Yen sign at U+00A5, and modern versions of Windows supports Unicode
Unicode
Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems...

 which has the Won sign at U+20A9, much software will continue to display backslashes found in ASCII files this way to preserve backwards compatibility.

Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, as a derivative of UNIX, uses UNIX paths internally. However, to preserve compatibility for software and familiarity for users, many portions of the GUI switch "/" typed by the user to ":" internally, and switch them back when displaying filenames (a ":" entered by the user is also changed into "/" but the inverse translation does not happen).

Uniform 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

Note: The UNC syntax sometimes appears written with forward slashes. Microsoft Windows treats forward slashes and back slashes in this context as equivalent, but many programs will accept only backward slashes, and some will only accept double backslashes (i.e. \\\\ComputerName\\SharedFolder), especially in quoted string constants, due to the standard use of backslash
Backslash
The backslash is a typographical mark used mainly in computing. It was first introduced to computers in 1960 by Bob Bemer. Sometimes called a reverse solidus or a slosh, it is the mirror image of the common slash....

 as an escape character
Escape character
In computing and telecommunication, an escape character is a character which invokes an alternative interpretation on subsequent characters in a character sequence. An escape character is a particular case of metacharacters...

.

The "SharedFolder" does not necessarily have the same name when viewed remotely as what a program on the server would see if it tried to open "\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,
  • uniform naming convention (UNC), such as \\Server\Volume\File,
  • Long UNC or UNCW, such as \\?\C:\File or \\?\UNC\Server\Volume\File.


In versions of Windows prior to Windows XP, only the APIs that accept "Long UNC" could accept more than 260 characters.

The shell in Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...

 and Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

, explorer.exe, allows path names up to 248 characters long.

POSIX pathname definition

A few Unix-like systems use a similar syntax.
POSIX
POSIX
POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

 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.
Many applications on Unix-like systems (for example, scp
Secure copy
Secure Copy or SCP is a means of securely transferring computer files between a local and a remote host or between two remote hosts. It is based on the Secure Shell protocol....

, rcp
Rcp (Unix)
rcp stands for the Unix 'remote copy' command. It is a command on the Unix operating systems that is used to remotely copy—to copy one or more files from one computer system to another...

 and rsync
Rsync
rsync is a software application and network protocol for Unix-like and Windows systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar...

) use resource definitions such as:

hostname:/directorypath/resource

or like URL
Uniform Resource Locator
In computing, a uniform resource locator or universal resource locator is a specific character string that constitutes a reference to an Internet resource....

s with the service name (here 'smb'):

smb://hostname/directorypath/resource

Unix style

The following worked example discusses the behavior of a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

-style file system
File system
A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...

 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 (file systems)
In computing, a folder, directory, catalog, or drawer, is a virtual container originally derived from an earlier Object-oriented programming concept by the same name within a digital file system, in which groups of computer files and other folders can be kept and organized.A typical file system may...

 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 to change the current working directory to bobapples:
cd bobapples

Two dots ("..") point upwards in the hierarchy
Hierarchy
A hierarchy is an arrangement of items in which the items are represented as being "above," "below," or "at the same level as" one another...

, to indicate the parent directory
Parent directory
In computing, the parent directory of a given directory A is the directory B in which A is located. In As absolute path, B is the predecessor of A....

; one dot (".") represents the current directory itself. Both can be components of a complex relative path (e.g., "../mark/./bobapples"), where "." alone or as the first component of such a relative path represents the working directory
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. When the process refers to a file using a simple file name or relative path , the reference is interpreted relative to the current working directory of...

. (Using "./foo" to refer to a file "foo" in the current working directory can sometimes usefully distinguish it from a resource "foo" to be found in a default directory or by other means; for example, to view a specific version of a manual page instead of the one installed in the system.)

MS-DOS/Microsoft Windows style

Contrary to popular belief, the Windows system API
Windows API
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name "Windows API" more accurately reflects its roots in 16-bit Windows and its support on...

 accepts forward 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
Cmd.exe
Command Prompt is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems...

 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
tcsh is a Unix shell based on and compatible with the C shell . It is essentially the C shell with programmable command line completion, command-line editing, and a few other features.-History:...

 and Windows PowerShell
Windows PowerShell
Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework...

, allow the forward 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 forward slashes.

The following examples show MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

/Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

-style paths, with backslashes used to match the most common syntax:

A:\Temp\File.txt

This path points to a file with the name File.txt, located in the directory Temp, which in turn is located in the root directory of the drive A:.

C:..\File.txt

This path refers to a file called File.txt located in the parent directory of the current directory on drive C:.

Folder\SubFolder\File.txt

This path denotes a file called File.txt located in SubFolder directory which in turn is located in Folder 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
Serial port
In computing, a serial port is a serial communication physical interface through which information transfers in or out one bit at a time...

 (COM1).

C:\>more < C:/Windows/system.ini
; for 16-bit app support
[386Enh]
woafont=dosapp.fon
EGA80WOA.FON=EGA80WOA.FON
EGA40WOA.FON=EGA40WOA.FON
CGA80WOA.FON=CGA80WOA.FON
CGA40WOA.FON=CGA40WOA.FON
...

This example uses a path containing forward 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 "[drive letter]:/Program Files" will only work from the root ([drive 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 %JAVA_HOME% 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
    Filename
    The filename is metadata about a file; a string used to uniquely identify a file stored on the file system. Different file systems impose different restrictions on length and allowed characters on filenames.A filename includes one or more of these components:...

  • Fully qualified file name
    Fully qualified file name
    The term fully qualified file name means a file on a computer whose exact name is completely specified such that it is unambiguous and cannot be mistaken for any other file on that system. It is somewhat equivalent on the Internet to a URL specifying the full name of the computer and the entire...

  • Filesystem Hierarchy Standard
    Filesystem Hierarchy Standard
    The Filesystem Hierarchy Standard defines the main directories and their contents in Linux operating systems. For the most part, it is a formalization and extension of the traditional BSD filesystem hierarchy....

     (FHS)
  • Uniform Resource Locator
    Uniform Resource Locator
    In computing, a uniform resource locator or universal resource locator is a specific character string that constitutes a reference to an Internet resource....

     (URL)
  • Device file
  • basename
    Basename
    basename is a standard UNIX computer program. When basename is given a pathname, it will delete any prefix up to the last slash character and return the result...

  • PATH (variable)
    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...

  • Distributed file system
    Distributed file system
    Network file system may refer to:* A distributed file system, which is accessed over a computer network* Network File System , a specific brand of distributed file system...

    (DFS)

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK