Find files by extension on a Mac
· 6 min read
To list every file of one type on a Mac, open a Finder window, press Cmd-F, click the plus button, and set the row to Name, ends with, then type the extension with its dot: .psd. That matches the extension itself rather than the loose category a plain search uses. Terminal does the same job with find when you want a list you can count, sort or pipe somewhere.
Search by extension in Finder
Finder’s search field looks like a single box and has a query builder underneath it.
- Open a Finder window at the disk or folder you want to search, then press Cmd-F.
- Under the search field, pick the scope. This Mac searches everything the index covers; the button showing a folder name searches only there.
- Click the plus button at the right of that row to add a criterion.
- Set the first pop-up to Name, the second to ends with, and type the extension including the dot.
- Press Cmd-2 for List view, then right-click a column heading and switch on Kind, Size and Date Modified so you can sort what comes back.
Two more criteria earn their place. Adding a System files row set to are included brings back results inside your Library folder, which Finder hides by default. And the first pop-up ends with Other, which opens the full list of attributes the index holds: creation date, pixel height, audio bit rate and dozens besides. Anything you tick there joins the pop-up permanently.
If you cannot see extensions on your files at all, Finder is hiding them. Open Finder, Settings, Advanced, and switch on Show all filename extensions. It makes every one of these searches easier to reason about.
Kind is not the same as extension
Typing kind:pdf into a Finder or Spotlight search field is quicker than building a criterion row, and it answers a slightly different question. Kind is a category macOS assigns to a file, not the letters after the dot. kind:image returns JPEG, PNG, HEIC, TIFF and camera raw files together. kind:movie covers MP4, MOV and more.
That is exactly what you want when the question is “show me every image on this disk”, and exactly wrong when the question is “show me the .tif files but not the .tiff ones”. Use kind for a family of formats and the Name ends with criterion when the extension itself matters.
While the subject is up: changing a file’s extension does not convert the file. Renaming a .heic to .jpg leaves the same bytes behind a misleading label, and Finder will warn you before it lets you do it. The warning is worth reading rather than clicking through.
Save the search as a Smart Folder
If you run the same search more than twice, stop retyping it. With the search results still on screen, choose File, then Save. Give it a name, and tick Add To Sidebar.
A saved search is a live query, not a folder of copies. Click it and Finder runs the search again, so a .dmg file downloaded this morning appears in the one you saved last year. They live in ~/Library/Saved Searches, and deleting one removes only the query.
Useful ones to keep: every disk image anywhere on the Mac, every .zip in Downloads, every file of whatever format your work produces so that a stray copy on the Desktop is visible instead of forgotten.
The same search from Terminal
When you want to count results, or feed them into something else, Terminal is better suited than Finder.
find ~ -type f -iname "*.psd" 2>/dev/null
-iname ignores case, so .PSD matches too. 2>/dev/null hides the permission complaints that find prints when it reaches folders it is not allowed to read. Add | wc -l to the end for a count, and replace ~ with any folder to narrow the search.
Sorted by size, biggest last:
find ~ -type f -iname "*.psd" -exec du -h {} + 2>/dev/null | sort -h
That is often the real question behind an extension search, and Find the largest files on a Mac covers the rest of it.
mdfind asks the Spotlight index instead of walking the disk, so it answers immediately:
mdfind "kMDItemFSName == '*.key'c"
The trailing c makes the match case-insensitive. Add -onlyin ~/Documents to restrict it to one folder. Because it reads the index, it is only as good as the index; if it returns nothing for a file you can see, Rebuild the Spotlight index on a Mac is the next stop.
To see which extensions a messy folder actually contains, before deciding what to search for:
find ~/Downloads -type f | awk -F. 'NF>1 {print tolower($NF)}' | sort | uniq -c | sort -rn
That prints a count per extension, commonest first. Files with no dot in their name are skipped, which is usually what you want.
Where these searches quietly miss files
None of the above sees everything, and the gaps are consistent.
- Inside packages. The Photos library and the Mail store look like single items in Finder and their contents do not appear in normal search results. Find a mail attachment on a Mac covers the attachment case specifically.
- Your Library folder, unless you add the System files criterion described above.
- Hidden files, meaning anything whose name starts with a dot.
- External drives that are not plugged in. Finder can only search what is mounted right now.
- Files with no extension at all. Unix executables and some app exports carry none. Search by Kind for those instead.
A search app that filters by type as you type
Everywhere catalogs every filename on the Mac once, then narrows as you type, with an ext: operator for exactly this job. Typing ext:psd lists every one of them across the whole disk, and you can stack operators: path:clients ext:psd restricts it to folders whose path contains “clients”, and a size: filter trims the result further. It suggests the operators as you type them, so there is no syntax to memorize.
Two limits worth stating plainly. It searches names and paths, never the text inside a file, so “the invoice that mentions the Reading office” is still a job for Spotlight. And it is not a launcher: it finds files and opens or reveals them, and does not run calculations or start apps by name.
Questions
Why does searching for .pdf in the Spotlight window return unrelated files?
The Spotlight window searches file contents as well as names, and it treats punctuation as a separator, so a document that merely mentions PDF can outrank the files you meant. Finder’s Name ends with criterion, or kind:pdf, gives you the precise version.
Can I search for two extensions at once?
A single Name row takes one value, so add a second criterion row for the other. In Terminal, group them: find ~ \( -iname "*.jpg" -o -iname "*.jpeg" \). In Everywhere, the | operator asks for either term in one query.
Does renaming the extension change the file? No. The bytes stay as they were; only the label changes, and apps that check the actual contents will still refuse to open it. Converting is a different operation entirely.
Why do some files have no extension? Because nothing requires one. Command line tools, files exported by apps that record the type in metadata, and anything created on a system that identifies files another way can arrive bare. Kind still classifies them correctly, which is why a kind search finds what an extension search cannot.