Finder fixes and how-tos
Finder has no obvious command that exports a folder's contents as a list, but two routes get the names out: copy and paste from Finder, or one Terminal command that writes a text file. Both below, with subfolders and sizes.
In Terminal, one command writes the names of everything in a folder to a text file on your Desktop:
ls -1 "/path/to/folder" > ~/Desktop/list.txt
Type ls -1 , drag the folder from Finder onto the Terminal window to fill in its path, then add > ~/Desktop/list.txt. Open list.txt and you have one name per line, ready to print or paste into a spreadsheet.
In Finder, click one file in the folder, press ⌘A to select all, press ⌘C, and paste into a plain-text document. What a paste produces depends on the app you paste into, so the steps below use TextEdit in plain-text mode. The Terminal route gives the same result every time.
The list goes to the Desktop on purpose. If you wrote list.txt into the folder you are listing, the file would appear in its own list.
To get the names into a spreadsheet, copy them from that TextEdit document and paste into Numbers or Excel; each line of plain text lands in its own row.
For full paths instead of names, select the files, hold Option and open the Edit menu: Copy turns into Copy “name” as Pathname, or Copy 3 Items as Pathnames for several (⌥⌘C). That is covered in how to copy a file path on a Mac.
All of these print to the window. Add > ~/Desktop/list.txt to any of them to save the output.
| You want | Command |
|---|---|
| Names, one per line | ls -1 |
| Names including hidden files | ls -1A |
| Sizes and dates | ls -lh |
Names, with a / after folders | ls -1p |
| The folder and everything inside it | find . -type f |
| Only this folder, not subfolders | find . -maxdepth 1 -type f |
| Straight to the clipboard | ls -1 | pbcopy |
Run them from inside the folder: type cd , drag the folder onto the window and press Return first. A few notes on how they behave, checked on a test folder:
ls -1 shows folders and files together and leaves out names that start with a dot. ls -1A includes them.ls -lh adds permissions, owner, a size such as 4.2M and the modification date.find . -type f lists files only, at every depth, each with a ./ in front, and it includes hidden files. To leave the dot-files out, use find . -type f -not -name '.*'.pbcopy puts the output on the clipboard as plain text, so ⌘V then pastes it anywhere.ls -R1 lists the folder and then each subfolder under its own heading, which reads well on screen. For a flat list with one full path per line, use find:
find "/path/to/folder" -type f > ~/Desktop/all-files.txt
Because you gave find the full path, every line begins with that path, so the list works as a record of exactly where each file was. If you only want the folder structure, the tree command draws it, and counting the files in a folder gives you the number rather than the names.
ls -lh is easy to read but awkward to import, because its columns are separated by spaces and file names can contain spaces too. For a list that opens in Numbers or Excel as two clean columns, write the size in bytes and the name separated by a tab:
find . -maxdepth 1 -type f -not -name '.*' -exec stat -f '%z%t%N' {} + > ~/Desktop/sizes.txt
Run it from inside the folder, as with the table above. Each line holds a size, a tab and a name such as ./a b.jpg. Drop -maxdepth 1 to include every subfolder, and the names then show the subfolder they're in. Names with spaces are fine in the list; if you later feed them to another command, put them in quotes.
If you only need the location of one file, you don't need a list. In Everywhere, type part of its name, select the result and press ⌘C to copy its full path. Type folder: to search folders only, or path:Invoices to restrict results to anything with that in its path. It lists matches rather than exporting a folder's contents, so for a complete list of one folder use the methods above.
Select the files in Finder with ⌘A, copy with ⌘C, and paste into a plain-text document. For a result that is identical every time, run ls -1 > ~/Desktop/list.txt in Terminal.
Create the list first, then print it. Paste the names into TextEdit and press ⌘P, or save the Terminal output to a text file and open it.
Save the names with ls -1 > ~/Desktop/list.txt and open that file in your spreadsheet app, or paste a plain-text list into it. For sizes in their own column, the stat -f '%z%t%N' command in this guide writes a tab-separated list.
Use find "/path/to/folder" -type f to list every file at every depth, or ls -R1 for a heading per subfolder. Add > ~/Desktop/list.txt to save it.
Everywhere keeps track of every file on your Mac, including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised