Copying a path to the clipboard in one move

The file is in front of you in a Finder window. The command that needs it is in a terminal two windows away, or in a chat box, or half typed into a script. Somewhere between those two points the location of that file has to turn into text, and the usual method is a small ritual: Get Info, squint at the Where field, retype it, get it wrong once. Anyone looking up mac finder copy path to clipboard has already decided that ritual is not sustainable. There is a built-in shortcut, it takes one keystroke, and it has one sharp edge that ruins about a third of the paths it produces.

The shortcut, and the modifier that reveals it

Select a file or folder in Finder and press Option+Command+C. The full POSIX path lands on the clipboard, ready to paste anywhere.

The reason so few people know about it is that the command is hidden behind a modifier key. Open the Edit menu with a file selected and it reads Copy "filename". Hold Option and the same entry changes to Copy "filename" as Pathname. The same substitution happens in the contextual menu: control-click a file, hold Option, and Copy becomes Copy as Pathname. Menu entries that appear only while a modifier is held are a long-standing macOS convention, and they are effectively invisible to anyone not already looking for them.

Two properties are worth knowing before relying on it.

Selecting several items copies several paths, one per line, in the order Finder has them sorted. That makes it a reasonable way to build a file list for a script, though the ordering follows the current view, not anything stable.

Selecting nothing and pressing the shortcut copies nothing. To copy the path of the folder currently open rather than an item inside it, click the folder in the path bar first, or press Command+Up to move into the parent and select it there. This catches people out constantly, because the window looks like it has a location selected when in fact only its contents are on screen.

The path arrives raw. It is not quoted, and spaces are not escaped. A path such as /Users/name/Client Work/Q3 report.pdf pastes exactly like that, and a shell reads it as three separate arguments. Nothing warns about this. The command simply fails, or worse, half succeeds against a file that happens to share the first word.

Five ways to get a path, compared

Copying is not the only route, and the alternatives differ in exactly the place that matters, which is what happens to spaces and to non-ASCII characters.

Method Escapes spaces Multiple items Where it works
Option+Command+C No Yes, one per line Any Finder selection
Drag the file into a Terminal window Yes, with backslashes Yes, separated by spaces Terminal only
pwd | pbcopy in a shell No Current directory only Terminal only
Get Info, Where field Not applicable One at a time Any Finder selection
Control-click in the path bar No The clicked folder only Finder, path bar visible

Dragging is the underrated entry in that table. Drop a file onto a Terminal window and the path is inserted at the cursor with every space and special character escaped, which is the correct form for a shell and the form Option+Command+C does not give. For a single file that is about to be typed after a command name, dragging is strictly better than copying.

The Get Info route is the one most people fall back on, and it is the weakest. The Where field shows the location using display names separated by chevrons, not a POSIX path, so it needs translating before it works anywhere. It is useful for reading, not for pasting.

Making a pasted path survive the shell

Three failure modes account for nearly all broken pastes, and each has a fixed answer.

Spaces and punctuation

Wrap the pasted path in double quotes. Type the opening quote, paste, type the closing quote, and the whole thing becomes one argument regardless of what is in it. This handles spaces, parentheses, ampersands, and the non-ASCII characters common in file names created outside English. Single quotes work too and are stricter, though they break on paths that themselves contain an apostrophe.

The trailing newline

Copying a path out of a terminal with pwd | pbcopy includes the newline that pwd prints. Pasted into a shell it just submits the line, which is usually harmless. Pasted into a chat box, a form field, or a note it can submit the message early or leave an invisible break in the middle of a sentence. printf '%s' "$PWD" | pbcopy copies the same path with nothing after it.

The tilde

~ expands to the home directory in a shell and in the Go to Folder field, and nowhere else. An application text field, a configuration file, or a message to someone on another machine needs the absolute form. Option+Command+C already produces the absolute form, so this only bites when a path is retyped from memory or lifted out of documentation.

Building a copy that quotes itself

Typing quotes around every paste works, and it is also the kind of small manual step that gets skipped at the wrong moment. macOS has a built-in way to replace it with a second shortcut that produces a shell-ready path directly.

Open Automator, create a new document, and choose Quick Action. Set the workflow to receive files or folders in Finder. Add a Run Shell Script action, set Pass input to "as arguments", and have the script print each argument wrapped in double quotes. Follow it with a Copy to Clipboard action, then save the workflow under a name such as Copy Quoted Path. It appears immediately in the Services section of the contextual menu for any file in Finder.

The keyboard shortcut is assigned separately, under System Settings, Keyboard, Keyboard Shortcuts, Services. Every workflow saved as a Quick Action for files and folders is listed there, along with the built-in entries such as New Terminal at Folder, and any of them can be given a key combination. The same panel is where entries that have gone missing from the menu can be switched back on, which is worth checking before concluding that a service does not exist on a particular machine.

The Shortcuts app covers the same ground with a different set of trade-offs. A shortcut set to appear in the Services menu, taking files as input and ending in Copy to Clipboard, produces the same result without touching a shell script. Automator gives finer control over the exact text, since the script decides the quoting; Shortcuts is easier to edit later and syncs between devices signed into the same account.

Either way the outcome is a second clipboard command sitting next to Option+Command+C: one that returns the raw path, one that returns a path that can be pasted after a command name without further thought. Choosing between them at the moment of copying is faster than repairing a broken command afterwards, and it removes the class of mistake where a path silently matches the wrong file because everything after the first space was discarded.

The paths that are not what they look like

Some locations produce a technically correct path that still fails when it reaches its destination, and it is worth recognizing them before losing time to one.

iCloud Drive is the most common. Finder presents it as a top-level item, and the path underneath is ~/Library/Mobile Documents/com~apple~CloudDocs followed by the rest. The path is valid. What is not guaranteed is that the file is actually on the disk, because a file kept in the cloud and not downloaded exists locally as a small placeholder. A command run against it may open a file that has no contents yet.

Mounted volumes are the second. External drives, disk images, and network shares all appear under /Volumes with the volume name as the next segment. Rename the drive and every stored path breaks. Two drives with the same name mount as Backup and Backup 1, in whichever order they happened to connect.

Case sensitivity is the third, and it is the one that shows up late. The default file system on a Mac is case-insensitive, so a path with the wrong capitalization works locally. The same path in a Docker build, on a Linux server, or in a repository shared with a case-sensitive system does not. A file reference that works on the machine and fails in continuous integration is usually this and nothing more exotic.

Not copying the path at all

Every path that gets copied is copied for a reason, and for the most common reason there is a shorter route. Apple documents it in the Terminal user guide.

Control-click the folder in the path bar, then do one of the following. Open a new window: Choose Open in Terminal. Open a new tab: Choose Services > New Terminal Tab at Folder. Source: support.apple.com

If the path bar is not visible, View then Show Path Bar, or Option+Command+P, brings it back. The Services entries live under System Settings, Keyboard, Keyboard Shortcuts, Services, in the Files and Folders group, where they can be switched on and given a shortcut of their own.

The reverse direction is equally short. open . opens a Finder window at the shell's current directory. open -R followed by a file name opens Finder with that file selected and highlighted. Between those two commands and the path bar menu, most of the copying disappears, because copying a path in order to type cd in front of it was never the goal.

What is left over is the case where the path has to go somewhere that is not a shell. A prompt to a coding assistant, a note, a ticket, a message. That is still a select, a shortcut, an application switch, a paste, and a check that nothing broke. Repeated across a working day it is the quiet tax that made the search happen in the first place, and it is the reason a folder view, a shell, and an assistant increasingly get built into one window instead of three. What that arrangement covers in practice is described under Features, and the trade-offs against the established options are set out in Compared with other file managers.

What to change first

Put Option+Command+C into muscle memory today, and get into the habit of typing the quotes before pasting into a shell. Then switch the path bar on and use Open in Terminal for a week, and count how many of the copies were only ever standing in for a cd. If the count is most of them, the clipboard was never the problem, and that is the gap Atriens was built to close.

Frequently asked questions

What is the shortcut to copy a file path on a Mac?

Option+Command+C, with the file selected in Finder. Holding Option changes the Copy entry in the Edit menu and the contextual menu to Copy as Pathname. Selecting several files copies one path per line.

Why does the copied path break in Terminal?

Because it is copied without quoting or escaping. A path containing a space is read by the shell as several separate arguments. Wrap the pasted path in double quotes, or drag the file into the Terminal window instead, which inserts the path with spaces escaped automatically.

How do you copy the path of the folder that is currently open?

Select the folder itself rather than an item inside it. Either click it in the path bar at the bottom of the window and press Option+Command+C, or press Command+Up to open the parent folder with the original selected, then use the shortcut.

How do you go the other way, from a path back to Finder?

Press Shift+Command+G in Finder to open the Go to Folder field and paste the path there. It accepts absolute paths and expands the tilde. From a terminal, open . opens the current directory in Finder and open -R with a file name reveals that file with it selected.

Back to all posts