10 Quick Ways to Copy a File Name on Windows and Mac
Keeping track of file names is a small but common task that comes up when sharing files, documenting assets, or organizing folders. Below are 10 fast, reliable ways to copy a file name on Windows and macOS — from single files to batches — with clear steps for each method.
1. Rename (select text) — Windows & Mac
- Windows: Select the file in File Explorer, press F2, then press Ctrl+C to copy the highlighted file name (without the extension if the engine hides it).
- Mac: Select the file in Finder, press Return, then press Command+C to copy the highlighted name.
2. Copy as Path — Windows
- In File Explorer, hold Shift, right-click the file, choose Copy as path. Paste to get the full path including the file name (enclosed in quotes). Trim the path to keep just the file name if needed.
3. Use Quick Actions / Services — Mac
- Select a file in Finder, right-click → Services → Copy Filename (if available) or create a custom Service in Automator that copies filenames to the clipboard.
4. Get Info / Properties dialog
- Windows: Right-click → Properties, copy the file name from the General tab.
- Mac: Right-click → Get Info, copy the file name from the Name & Extension field.
5. Terminal / Command Prompt — single file
- Windows Command Prompt:
- Navigate to the folder, run:
echo %~n1(for scripts) orfor %f in (“filename.ext”) do @echo %~nxfto print name and extension.
- Navigate to the folder, run:
- macOS Terminal:
- Run:
basename “/path/to/filename.ext”— copies the file name (usepbcopyto send to clipboard:basename “/path/to/filename.ext” | pbcopy).
- Run:
6. PowerShell and macOS shell — copy directly to clipboard (single file)
- PowerShell (Windows):
Split-Path -Leaf “C:\path\to\file.ext” | Set-Clipboard
- macOS zsh/bash:
basename “/path/to/file.ext” | pbcopy
7. Batch copy file names to clipboard — Windows
- PowerShell from inside a folder:
Get-ChildItem -File | Select-Object -ExpandProperty Name | Set-Clipboard- This copies all file names in the current directory to the clipboard as a list.
8. Batch copy file names to clipboard — macOS
- Terminal in a folder:
ls -1 | pbcopy- Or for full names including paths:
find . -maxdepth 1 -type f -print | sed ’s|^./||’ | pbcopy
9. Use a file manager or utility app
- Windows: Third-party tools like Total Commander or FreeCommander offer built-in commands to copy file names or full paths.
- Mac: ForkLift or Path Finder provide enhanced copy options (including copying names, extensions, and paths) via menus.
10. Automator / Scripts — custom workflows
- macOS Automator: Create a Service that receives files in Finder, runs a script to extract names, then copies them to the clipboard. Save it for repeated use.
- Windows: Create a small PowerShell script or batch file that you can run from the context menu using registry tweaks or a shortcut.
Quick examples (copy to clipboard)
- Windows PowerShell (current folder):
Get-ChildItem -File | Select-Object -ExpandProperty Name | Set-Clipboard
- macOS Terminal (current folder):
ls -1 | pbcopy
- Single file (macOS):
basename “/Users/you/Documents/report.pdf” | pbcopy
- Single file (Windows PowerShell):
- `Split-Path -Leaf “
Leave a Reply