Path (computing)
A path (or filepath, file path, pathname, or similar) is a string that uniquely identifies an item in a hierarchical file system.
≈ 16 min read
Path (computing). encyclopegia.org, snapshot enwiki-001378833930. /a/path-computing
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
A path (or filepath, file path, pathname, or similar) is a string that uniquely identifies an item in a hierarchical file system. Generally, a path is composed of directory names, special format specifiers, and optionally a filename, all separated by delimiters. This delimiter can vary by operating system, but popular, modern systems use the slash /, backslash \, or colon :.
The case-sensitivity of individual path components will vary based on operating system, or based on options specified at the time of a file system's creation or first use. In practice, this means that for a case-sensitive system, path components named component1 and Component1 can coexist at the same level in the hierarchy, whereas for a case-insensitive file system, they cannot (an error will occur). macOS and Windows' native file systems are case-insensitive by default, whereas typical Linux file systems are case-sensitive.[1][2][3]
A path can be either relative or absolute. A relative path is a path in relation to another, most often the working directory. An absolute path indicates a location regardless of the current directory; that is, it specifies all path components starting from the file system's root, and does not depend on context like a relative path does.
Paths are also essential for locating hierarchically-organized network resources, as seen in URLs and UNC paths.
History
edit edit sourceMultics first introduced a hierarchical file system with directories (separated by ">") in the mid-1960s.[4]
Around 1970, Unix introduced the slash / as its directory separator.
Originally, MS-DOS did not support directories. When adding the feature, using the Unix standard of a slash was not a good option since many existing commands used a slash as the switch prefix (i.e., dir /w). In contrast, Unix uses the dash - as the switch prefix. The backslash \ was ultimately chosen instead for its similarity to the slash and not conflicting with existing commands. This convention continued into Windows. However, some areas of Windows do accept or understand Unix-style slashes also, such as PowerShell.[5][6]
Summary of systems
edit edit sourceThe following table describes the syntax of paths in notable operating systems:
| System | Root dir. | Path delim. | Working dir. | Parent dir. | Home dir. | Examples |
|---|---|---|---|---|---|---|
| Unix and Unix-like systems, including macOS[7] | / | / | . | .. | ~ | /home/user/docs/Letter.txt ./child ../../greatgrandparent ~/.rcinfo |
| Windows, Command Prompt | \ (relative to current working directory root) or [drive letter]:\ or \\.\ or \\?\ or \\[Host name]\[Root name] (UNC) |
/[a] or \ |
. | .. | C:\user\docs\Letter.txt /user/docs/Letter.txt C:\user\docs\somefile.ext:alternate stream name C:picture.jpg | |
| PowerShell | [drive letter]:/ or [drive name]:\ or [PSSnapIn name]\[PSProvider name]::[PSDrive root] or UNC |
/[a] or \ |
. | .. | ~ | C:\user\docs\Letter.txt ~\Desktop UserDocs:/Letter.txt Variable:PSVersionTable Registry::HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft.PowerShell.Security\Certificate::CurrentUser\ |
| UNC[8] | \\[server]\[sharename]\ | / | \\Server01\user\docs\Letter.txt | |||
| DOS, COMMAND.COM | [drive letter]:\ or \\[server name]\[volume]\ |
\ | . | .. | C:\USER\DOCS\LETTER.TXT A:PICTURE.JPG \\SERVER01\USER\DOCS\LETTER.TXT | |
| OS/2 | [drive letter]:\ or \\[server name]\[volume]\ |
/ or \ |
. | .. | C:\user\docs\Letter.txt A:Picture.jpg \\SERVER01\USER\docs\Letter.txt | |
| RSX-11 MCR[9] | [device name]: | DR0:[30,12]LETTER.TXT;4[b] | ||||
| TOPS-20 DCL[10] | [device name]: | . | PS:<USER.DOCS>LETTER.TXT,4 | |||
| OpenVMS DCL[11][12] | [device name]:[000000] or [NODE["accountname password"]]::[device name][000000]: |
. | [] | [-] | SYS$LOGIN: | NODE$DISK:[USER.DOCS]PHOTO.JPG USER:[000000]000000.DIR []IN_THIS_DIR.COM; [-.-]GreatGrandParent.TXT SYS$SYSDEVICE:[.DRAFTS]LETTER.TXT;4 GEIN::[000000]LETTER.TXT;4 SYS$LOGIN:LOGIN.COM |
| ProDOS AppleSoft BASIC[13] | /[volume or drive name]/ | / | /SCHOOL.DISK/APPLEWORKS/MY.REPORT FLIGHT.SIMULATOR,D2 | |||
| AmigaOS Amiga CLI / AmigaShell[14] | [drive, volume, device, or assign name]: | / | empty string | / | Workbench:Utilities/MultiView DF0:S/Startup-Sequence S:Startup-Sequence TCP:en.wikipedia.com/80 | |
| RISC OS ShellCLI[15] | [fs type[#option]:][:drive number or disc name.]$[c] | . | @ | ^ | & | ADFS::MyDrive.$.Documents.Letter Net#MainServer::DataDrive.$.Main.sy10823 LanMan::WindowsC.$.Pictures.Japan/gif NFS:&.!Choices ADFS:%.IfThere @.inthisdir ^.^.greatgrandparent[d] |
| Symbian OS File manager | \ | \ | \user\docs\Letter.txt | |||
| Domain/OS Shell[16] | // (root of domain) or / (root of current node) |
/ | . | \ | ~ | //node/home/user/docs/Letter.txt ./inthisdir \\greatgrandparent ~rcinfo |
| MenuetOS CMD | / | / | /file | |||
| Stratus VOS CLI | %[system_name]#[module_name]> | > | < | %sysname#module1>SubDir>AnotherDir | ||
| NonStop Kernel TACL[e] |
. | \NODE.$DISK.SUBVOL.FILE \NODE.$DEVICE \NODE.$DEVICE.#SUBDEV.QUALIFIER | ||||
| CP/M CCP[17] | [drive letter:] | no subdirectories, only user areas 0–F | A:LETTER.TXT | |||
| GS/OS | :[volume name]: or .[device name]: or [prefix]:[f] |
: or / |
@ | :Apps:Platinum.Paint:Platinum.Paint *:System:Finder .APPLEDISK3.5B/file | ||
| OpenHarmony exec, Oniro, including HarmonyOS[18][19] | hb set -root [ROOT_PATH] or hb set -p --product [PRODUCT_NAME] |
> or / | ./ | ../ | LOCAL/MEDIA_TYPE_/Download/Letter.txt | |
In programming languages
edit edit sourceMost programming languages use the path representation of the underlying system, but some may also be system-independent.[2]
For instance, this C code is system-dependent and may fail on opposing systems:[1]
uxFile = fopen("project/readme.txt", "r") // Fails on Windows winFile = fopen("C:\\Program Files\\bin\\config.bat", "r") // Fails on Unix- In Java, the File.separator field stores the system-dependent separator.[20] Some functions preclude the need for the separator entirely.
- import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; // ... File file = new File("path" + File.separator + "file.txt"); Path path = Paths.get("path", "file.txt");
- from pathlib import Path with (Path("path") / "to" / "file.txt").open() as open_file: ...
In Unix
edit edit sourceMost Unix-like systems use a similar syntax.[22] POSIX allows treating a path beginning with two slashes in an implementation-defined manner,[23] though in other cases systems must treat consecutive slashes as one.[24]
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'), like smb://hostname/directorypath/resource.[3]
In macOS
edit edit sourceWhen macOS was being developed, it inherited some pathname choices from Classic Mac OS and the Unix-like NeXTSTEP. The classic Mac OS uses a : while Unix and Unix-like systems use a / as the path delimiter. As a solution, to preserve compatibility for software and familiarity for users, and to allow disk file systems to be used both by the classic Mac OS and macOS, some portions of macOS convert between colons and slashes in pathnames;[25] for example, the HFS+ file system, from the classic Mac OS, converts colons in file names to slashes and, when reading a directory, converts slashes in filenames to colons,[26] and the Carbon toolkit converts colons in pathnames to slashes and slashes in path names to colons, and converts them back when providing filenames and pathnames to the caller.[26]
In DOS and Windows
edit edit sourceDOS and Windows have no single root directory; a root exists for each storage drive, indicated with a drive letter or through UNC.
Directory and file name comparisons are case-insensitive: "test.TXT" would match "Test.txt".[27]
Windows understands the following kinds of paths:
- Local paths, such as
C:\File. - Universal naming convention (UNC).
- DOS device paths, such as
\\.\C:\Fileor\\?\UNC\Server\Volume\File. The first,\\?\skips path normalization. The second,\\.\uses the raw device namespace.[27][28]
In the Windows API, file I/O functions automatically convert / into \ (except when using the \\?\ prefix). Paths using standard Windows APIs (dating back to DOS and Win9x), were limited to 260 characters, or less, as defined by the environment variable MAX_PATH. For backwards compatibility with legacy applications this limitation was not removed until Windows 10, build 1607, when it could be expanded to 32,767. Windows NT always supported the 32,767 path length internally but only if using Unicode APIs or forcing UNC paths by the \\?\ prefix.[29]
PowerShell allows slash-interoperability for backwards-compatibility:[30]
PS C:\>Get-Content -Path "C:/path/to/file.txt" Here is some text within a fileYen/won character error
edit edit sourceJapanese and Korean versions of Windows often displayed the '¥' character or the '₩' character instead of the directory separator. This is because, while in ANSI codepages the character at 0x5C was the backslash, in Japanese and Korean codepages 0x5C was the yen and won signs, respectively. Therefore, when the character for a backslash was used, other glyphs appeared.[31]
Universal Naming Convention
edit edit source
The Microsoft Universal Naming Convention (UNC, uniform naming convention, or network path), is a syntax to describe the location of a network resource, such as a shared file, directory, or printer. A UNC path has the general form:[2]
\\ComputerName\SharedFolder\Resource
Some Windows interfaces 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. Thus, the WebDAV URL of https://hostname:443/SharedFolder/Resource becomes \\hostname@SSL@443\SharedFolder\Resource.[32]
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 during creation of the share.
Since UNCs start with two backslashes, and the backslash is also used for escape sequences and in regular expressions, cases of leaning toothpick syndrome may arise. 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, such as @"\\\\" in C#, r'\\\\' in Python, or qr{\\\\} in Perl.
See also
edit edit source- basename – Shell command for extracting the last name from a path
- Device file – Interface to device driver that appears in filesystem
- dirname – Shell command for extracting the directory path portion from a path
- Distributed file system – Type of decentralized filesystemPages displaying short descriptions of redirect targets
- Filename – Text string used to uniquely identify a computer file
- Filesystem Hierarchy Standard – Linux standard for directory structure
- Fully qualified file name – Unambiguous name in computer codePages displaying short descriptions of redirect targets
- PATH (variable) – Computer environment variable
- URL – Address on the World Wide Web
Notes
edit edit source- ^ a b Limited compatibility, may not work in all Windows programs Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ In order, the fields are
ddnn:[g,m]:filename.type;versionWikipedia revision 1378833930, retrieved 2026-11-22 - ^
&,%, and@can also be used to reference the root of the current user, the library, and the current directory respectively Wikipedia revision 1378833930, retrieved 2026-11-22 - ^ When filesystems with filename extensions are mounted,
.characters are changed to/, as in the Japan/gif example above Wikipedia revision 1378833930, retrieved 2026-11-22 - ^ Short for Tandem Advanced Command Language Wikipedia revision 1378833930, retrieved 2026-11-22
- ^
[prefix]may be a number (0–31),*(boot volume) or@(AppleShare home directory) Wikipedia revision 1378833930, retrieved 2026-11-22
References
edit edit source- ^ a b "File system formats available in Disk Utility on Mac". Apple Support. Retrieved 12 September 2025. Includes a description of APFS, the default file system for macOS Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ a b c Matt Wojciakowski. "Case Sensitivity". learn.microsoft.com. Retrieved 12 September 2025. Windows file system treats file and directory names as case-insensitive. FOO.txt and foo.txt will be treated as equivalent files. Linux file system treats file and directory names as case-sensitive. FOO.txt and foo.txt will be treated as distinct files. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ a b Day, Brittany. "Understanding the Linux Filesystem Case Sensitivity Debate". Linux Security. Retrieved 12 September 2025. Case sensitivity in Linux refers to files and directories recognizing differences between lowercase and uppercase characters in filenames. For instance, "File.txt" and "file.txt" would both be treated as two distinct files. This concept is integral to Unix-like operating systems, including Linux. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Daley, R.C.; Neumann, P.G. (1965). "A general-purpose file system for secondary storage". Proceedings of the November 30--December 1, 1965, fall joint computer conference, Part I on XX - AFIPS '65 (Fall, part I). Vol. Part I. pp. 213–229. doi:10.1145/1463891.1463915. S2CID 16236414. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "Why Windows Uses Backslashes and Everything else Uses Forward Slashes". 10 February 2014. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "Why is the DOS path character "\"?". 24 June 2005. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "File System Basics". developer.apple.com. 9 April 2018. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "UNC Network Share Access (Windows)". www.ibm.com. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ RSX-11M-PLUS MCR Operations Manual, RSX-11M-PLUS Version 4.0 (PDF). Digital Equipment Corporation. August 1987. 2.2 File Specifications. AA-JS12A-TC. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Herkert, Mark Klause Herman; Smith, Sheri Lynn (December 1985). Defense Data Network/TOPS-20 Tutorial. An Interactive Computer Program (PDF) (Technical report). Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Rabe, Bernhard (6 June 2011). "OpenVMS & DCL on Alpha & VAX" (PDF). Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "VSI OpenVMS User's Manual" (PDF). VMS Software. 2025. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ ProDOS User's Manual. Apple Computer. 1983. pp. 56–62. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ The AmigaDOS Manual. Produced by Commodore-Amiga, Inc. Bantam Computer Books. February 1986. pp. 6–16. ISBN 978-0-553-34294-9.
{{cite book}}: CS1 maint: others (link) Wikipedia revision 1378833930, retrieved 2026-11-22 - ^ "RISC OS PRMs: Volume 2: Chapter 44: Writing a filing system". www.riscos.com Technical Support: Programmer's Reference Manual. 3QD Developments Ltd. 3 November 2015. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Getting Started with Domain/OS (PDF). Apollo Computer. May 1988. pp. 7-1 – 7-7. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ CP/M Operating System Manual (3rd ed.). Digital Research. September 1983. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "Introduction to the Shell". GitHub. OpenAtom OpenHarmony. Retrieved 13 March 2024. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "exec". GitHub. OpenAtom OpenHarmony. Retrieved 14 March 2024. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "Java Development Kit Version 17 API Specification". docs.oracle.com. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "pathlib — Object-oriented filesystem paths". Python. Retrieved 7 October 2026. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "UNC Definition". ComputerLanguage.com. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "POSIX pathname resolution specification". Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "POSIX pathname definition". Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Chan, Alex (1 December 2021). "A tale of two path separators". alexwlchan.net. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ a b Sanches, Wilfredo (2000). "The Challenges of Integrating the Unix and Mac OS Environments". Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ a b De George, Andy (14 December 2022). "File path formats on Windows systems". Microsoft Docs. Retrieved 14 July 2019. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Ashcraft, Alvin (28 August 2024). "Naming Files, Paths, and Namespaces". Microsoft Docs. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Ashcraft, Alvin (16 July 2024). "Maximum Path Length Limitation - Win32 apps". learn.microsoft.com. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ Wheeler, Sean. "about_Path_Syntax - PowerShell". learn.microsoft.com. Retrieved 7 September 2025. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "When is a backslash not a backslash?". Sorting it all Out. Wikipedia revision 1378833930, retrieved 2026-11-22
- ^ "DavGetHTTPFromUNCPath function". WebDAV: Windows. Microsoft Docs. series. 13 October 2021. Retrieved 4 October 2023. Wikipedia revision 1378833930, retrieved 2026-11-22
Text derived from https://en.wikipedia.org/w/index.php?oldid=1378833930 under CC BY-SA 4.0; modifications have been made.