Copy a List of File Names to the Clipboard

Pipe Get-ChildItem's Name property into Set-Clipboard (or dir /b into clip) to copy a clean file listing.

WindowsFilespowershellclipboardLow risk
Run Get-ChildItem 'C:\folder' -File | Select-Object -ExpandProperty Name | Set-Clipboard, then paste anywhere.

01Command

Command
$ Get-ChildItem 'C:\Users\me\Documents' -File |
  Select-Object -ExpandProperty Name | Set-Clipboard

02What it does

Right-click copy in Explorer copies the files themselves, not their names — this one-liner gives you a plain text list instead. Add -Recurse for subfolders, or pipe FullName instead of Name when paths are needed. The cmd equivalent is dir /b 'C:\folder' | clip; combining with findstr lets you filter names before copying.

03Risk

RiskLow risk

04Undo

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

05Sources

  • Set-Clipboard
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Set-Clipboard places piped strings (e.g. file names from Get-ChildItem) onto the Windows clipboard.
  • CLIP - SS64
    SS64 · technical · 2026-09-17
    Evidence: clip.exe reads piped input onto the clipboard; dir /b | clip lists bare file names in cmd.

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

06Related solutions