Copy a List of File Names to the Clipboard

Send folder listings or command output straight to the macOS clipboard.

macOSpbcopyFilesautomationclipboardLow risk
Run `ls -1 <folder> | pbcopy` and paste the names anywhere; use `pbpaste` to read the clipboard back.

01Command

Command
$ ls -1 ~/Downloads | pbcopy

02What it does

`pbcopy` reads standard input onto the pasteboard, so any listing can become clipboard text — filter with grep first to copy only PDFs, or use `find . -type f -name '*.png' | pbcopy` for a recursive list. The companion `pbpaste` lets scripts read the clipboard too.

03Risk

RiskLow risk
!Warning: `ls -1` gives names only; add `ls -d */*` style paths or `find` if you need full paths. The clipboard is shared system-wide — the next copy anywhere overwrites it.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions