How to Copy the Path of a File on Windows, Mac, and Linux

Knowing how to copy a file path is one of those small skills that quietly saves a lot of time. Whether you're pasting a location into a terminal, sharing a file reference with a colleague, or configuring software that needs to know where a file lives, copying the exact path eliminates typos and guesswork. The method varies depending on your operating system — and sometimes your workflow.

What Is a File Path?

A file path is the full address of a file on your system. It tells your operating system (or any application) exactly where a file is stored, starting from the root of the drive and working through each folder.

On Windows, a path looks like this: C:UsersYourNameDocuments eport.pdf

On macOS and Linux, paths use forward slashes: /Users/YourName/Documents/report.pdf

The path can be absolute (full address from the root) or relative (relative to a current working directory). Most situations where you need to copy a path — dragging it into a terminal, sharing it, or pasting it into settings — call for the absolute path.

How to Copy a File Path on Windows

Windows offers several methods depending on your version and comfort level.

Using File Explorer (Easiest Method)

  1. Navigate to the file in File Explorer
  2. Hold Shift, then right-click the file
  3. Select "Copy as path" from the context menu
  4. Paste it anywhere with Ctrl + V

The result is wrapped in quotation marks, like "C:UsersYourNameDocuments eport.pdf" — useful for command-line use where spaces in folder names would otherwise cause errors.

On Windows 11, you no longer need to hold Shift. Right-click the file and the "Copy as path" option appears directly in the streamlined context menu.

Using the Address Bar

  1. Click on any file to select it
  2. Click into the address bar at the top of File Explorer — it will switch from the breadcrumb view to the full path
  3. Ctrl + A to select all, then Ctrl + C to copy

This gives you the folder path, not the full path including the filename. Useful when you need the containing directory rather than the specific file.

Using PowerShell or Command Prompt

If you're already working in a terminal:

Get-Item "filename.txt" | Select-Object -ExpandProperty FullName 

Or in Command Prompt:

cd path ofolder echo %cd%filename.txt 

How to Copy a File Path on macOS 🍎

Using the Finder

  1. Right-click (or Control-click) the file in Finder
  2. Hold the Option key — the context menu will change
  3. "Copy [filename]" becomes "Copy [filename] as Pathname"
  4. Paste with Cmd + V

Without holding Option, Finder copies the file itself (for pasting as a file in another location), not the path text. This is a common source of confusion.

Using the Get Info Window

  1. Select the file and press Cmd + I to open Get Info
  2. Look at the "Where:" field — this shows the containing folder path
  3. You'll need to manually combine it with the filename for the full path

Using Terminal

If you're comfortable with the command line, drag a file directly into a Terminal window. macOS will automatically paste the full file path as text. This is fast and accurate, especially for deeply nested files.

# Or use this to print the full path: realpath filename.txt 

How to Copy a File Path on Linux

Linux users typically work in the terminal, so the options are well-suited to that environment.

In the Terminal

realpath filename.txt 

This outputs the absolute path. You can pipe it to your clipboard manager:

realpath filename.txt | xclip -selection clipboard # or realpath filename.txt | xsel --clipboard --input 

The exact clipboard tool (xclip, xsel, or wl-copy on Wayland) depends on your desktop environment and distribution.

In a File Manager (GUI)

Most Linux file managers — including Nautilus (GNOME), Dolphin (KDE), and Thunar (XFCE) — have a "Copy Location" or "Copy Path" option when you right-click a file. Dolphin also shows the full path in the address bar, which you can click to edit and copy directly.

Variables That Affect Which Method Works for You

FactorWhat Changes
Operating system versionWindows 11 simplifies the right-click menu; older Windows requires Shift+right-click
Wayland vs X11 (Linux)Clipboard tools differ between display servers
File manager choiceGUI options vary across Nautilus, Dolphin, Thunar, etc.
Use caseCommand-line use benefits from quoted paths; sharing with colleagues may need a cleaner format
Path type neededAbsolute vs relative paths serve different purposes in scripts and apps

When Paths Include Spaces

Spaces in folder or file names cause issues in terminals and scripts. On Windows, the "Copy as path" method wraps the result in quotes automatically. On macOS and Linux, you may need to add quotes manually or use escape characters (/Users/Your Name/Documents/).

If you're copying paths for use in code, scripts, or configuration files, always check whether the receiving application expects quotes, escaped spaces, or neither.

Path Format Differences Matter More Than They Seem

Even if you nail the copy method, format mismatches can break things. Windows paths use backslashes; Unix-based systems use forward slashes. Some cross-platform tools accept either, but others don't. If you're copying a path from Windows and pasting it into a Linux environment (or vice versa), you may need to convert the separators manually or with a find-and-replace.

Network paths add another layer — UNC paths on Windows (\ServerSharefolderfile.txt) look nothing like mounted network paths on macOS or Linux (/Volumes/Share/folder/file.txt), even when pointing to the same file.

The right method, format, and level of care depends heavily on what you're doing with the path once you have it — and that's where your specific setup and workflow become the deciding factor.