A file path is just the address of a file: the exact list of folders you would walk through to reach it, written as one line of text. C:\Users\Sam\Documents\report.pdf on Windows, or /Users/sam/Documents/report.pdf on a Mac. You need to copy one more often than you would think: pasting it into a command, attaching it to a bug report, pointing a config file at it, or just telling a colleague exactly where something lives. The good news is that every operating system has a one-click or one-shortcut way to grab it. You rarely need to type a path by hand.
What is a file path?
A file path is the address of a file or folder on your computer. It lists every folder from the top of the drive down to the file itself, so any program can find it without you pointing. Two examples:
- Windows: C:\Users\sam\Documents\report.pdf. It starts with a drive letter and uses backslashes.
- Mac and Linux: /Users/sam/Documents/report.pdf. It starts with a single slash and uses forward slashes.
A path that starts at the drive or the root is a full path (also called an absolute path). A path that starts from wherever you already are, like Documents/report.pdf, is a relative path. Programs, support forms and command lines almost always want the full one, which is what every method below copies.
How do I copy a file path?
- Windows 11: right-click the file and choose Copy as path, or select it and press Ctrl+Shift+C.
- Windows 10: hold Shift, right-click the file, choose Copy as path.
- Mac: select the file in Finder and press Option+Cmd+C.
- Linux: drag the file into a terminal window, or run realpath filename.
- Any terminal: pwd prints the folder you are in.
- VS Code: right-click the file in the sidebar and choose Copy Path.
Each of these puts the path on your clipboard, and your next copy replaces it. A clipboard manager like Relic keeps the paths you copied, so you can search for one again later on Windows, Mac, Linux, Android and iPhone.
How do I copy a file path in Windows 11?
Windows gives you a built-in option that copies the full path in one move, and it has been there since Windows 7. There is no need to install anything.
The Shift + right-click method (the reliable one)
- Find the file or folder in File Explorer.
- Hold Shift and right-click it.
- Choose Copy as path from the menu.
That puts the complete path on your clipboard, wrapped in double quotes. The quotes are deliberate: they keep the path in one piece if it contains spaces, which matters the moment you paste it into a terminal. On Windows 11 you do not even need the Shift key any more. Right-click the file, open the menu, and Copy as path is right there.
The address bar method (no quotes)
If you want a folder path without the surrounding quotes, click into the address bar at the top of File Explorer. The friendly breadcrumb turns into the raw path, already highlighted. Press Ctrl+C and you have it. This copies the folder you are in rather than a specific file, so it is best when you need a directory.
How do I copy a file path on a Mac?
macOS hides this behind a modifier key, which is why so many people think it is not possible. It is, and it is quick once you know the trick.
The Option-key method
- Select the file in Finder.
- Right-click (or two-finger tap on the trackpad) to open the menu.
- Hold Option. The Copy entry changes to Copy as Pathname.
- Click it. The full path is now on your clipboard.
The keyboard version is Option+Cmd+C with the file selected in Finder. It does the same thing with no menu. If you only want to read the path, select the file and press Cmd+I to open Get Info: the Where line shows the folder it lives in.
Mac paths use forward slashes and start from the root, like /Users/sam/Documents/report.pdf. Unlike Windows, macOS does not add quotes, so if the path contains spaces you may need to wrap it yourself before pasting it into a command.
Drag into Terminal
There is an even faster way when the path is destined for a command line. Open Terminal, start typing your command, then drag the file from Finder straight into the Terminal window. macOS types the full, correctly escaped path for you, spaces and all. It is the most reliable way to get a path into a command without a single typo.
Copy a file path on Linux
Linux file managers differ by desktop, but two methods work almost everywhere.
- Drag it into a terminal. Open a terminal window, then drag the file from the file manager into it. The terminal types the full path for you, with spaces escaped.
- Copy the folder from the location bar. In GNOME Files, press Ctrl+L and the breadcrumb turns into an editable path you can select and copy with Ctrl+C. Add the file name yourself.
- KDE Dolphin has a Copy Location entry in the right-click menu that copies the full path of the selected file.
From the command line, realpath filename prints the full path. To put it straight on the clipboard, pipe it: realpath filename | xclip -selection clipboard on X11, or realpath filename | wl-copy on Wayland. Both tools may need installing first.
Copy a file path in the terminal
If you are already in a terminal, you usually want to print a path rather than copy it from a window. The commands differ by system, and so do the copy and paste shortcuts. We cover the full set of rules in our guide to copying and pasting in the terminal, but here is the short version.
- macOS and Linux: run pwd to print your current folder, or realpath filename to print the full path to a specific file. On a Mac you can pipe it straight to the clipboard with pwd | pbcopy.
- Windows PowerShell: Get-Location shows the current folder, and (Resolve-Path filename).Path | Set-Clipboard copies a file’s full path in one line.
One thing to remember in any terminal: Ctrl+C does not copy. It cancels the running command. To copy and paste in most terminals you use Ctrl+Shift+C and Ctrl+Shift+V instead. On a Mac Terminal, the normal Cmd+C and Cmd+V work as you would expect.
Copy a file path in VS Code and other editors
Code editors have their own copy commands, and they are usually the quickest route when the file is already open.
- VS Code: right-click a file in the Explorer sidebar or on its tab. Copy Path gives the full path (Shift+Alt+C on Windows and Linux, Option+Cmd+C on a Mac). Copy Relative Path gives the path from the project folder (Ctrl+K Ctrl+Shift+C, or Cmd+K Cmd+Shift+C on a Mac).
- JetBrains editors (IntelliJ, PyCharm, WebStorm): right-click the file and choose Copy Path/Reference, then pick the absolute path or the path from the project root.
- Word, Excel and PowerPoint: open File, then Info. The Copy path button under the file name copies where the open document is saved.
Full path, relative path, or just the file name?
The methods above all copy the full path, also called the absolute path, which starts at the drive or root and works from anywhere. Sometimes you want less than that.
- Just the file name: click the file once to select it, press F2 (Windows) or Return (Mac) to enter rename mode, then Ctrl+C or Cmd+C. You get the name without the folders. Press Escape to leave rename mode without changing anything.
- A relative path: this describes where a file sits compared to where you are, like ..\images\logo.png. There is no menu button for it. You usually build it by hand or let your code editor generate it when you import or link a file.
Common snags and how to fix them
- The path broke at a space. A command read C:\My Files\a.txt as two separate things. Wrap the whole path in double quotes, which is exactly why Windows adds them for you.
- Wrong slashes. Windows writes backslashes and Mac and Linux write forward slashes. If you move a path between systems, you may need to swap them. Many tools on Windows now accept either.
- You copied the wrong thing. Copy as path grabs whatever is selected, so double-check the highlight before you copy, especially in a folder full of similar names.
None of this is hard, and once the shortcut is in your fingers you stop thinking about it. If you find yourself reaching for the same paths and commands over and over, a clipboard manager that keeps a searchable history saves you digging them out a second time.
Sources
- Get file, folder, and disk information on Mac, Apple Support
- Set-Clipboard, Microsoft Learn
- Editor basics: Copy Path/Reference, JetBrains IntelliJ IDEA docs
- Default keyboard shortcuts reference, Visual Studio Code docs