How to List Only Files, Not Folders, in the Terminal with find -type f
find <folder> lists everything under a folder: the folder itself, every folder inside it and every file. Add -type f and it lists only the files; add -type d and it lists only the folders. In PowerShell, Get-ChildItem -Recurse -File lists only the files.
This guide lists a small practice folder, with real output from macOS 26 and PowerShell 7.6.10.
Syntax
find <folder> -type f
find <folder> -type d
Get-ChildItem -Recurse -File -Name <folder>
Get-ChildItem -Recurse -Directory -Name <folder>
| Part | What it means |
|---|---|
find | Goes through a folder and every folder inside it, and lists what it finds |
<folder> | Where to start. . means the folder you're in |
-type f | Only regular files |
-type d | Only folders, which the manual calls directories |
Get-ChildItem | The PowerShell command that lists what's in a folder |
-Recurse | Goes into every folder inside it too |
-File / -Directory | Only files / only folders |
-Name | Prints only the names, as paths relative to <folder> |
The macOS manual page, man find, says find recursively descends the directory tree for each path listed, and describes -type t as True if the file is of the specified type, where f stands for regular file and d for directory. Microsoft's documentation for Get-ChildItem says: To get a list of files, use the File parameter. You can use the Recurse parameter with File.
The Example
A folder called trip holds a file, packing-list.txt, and three folders: days, with day-1.txt and day-2.txt, photos, with beach.jpg, and tickets, which is empty. You list it all, then only the files, then only the folders.
Step 1: Create the Practice Folder
- bash / zsh
- PowerShell
mkdir -p trip/days trip/photos trip/tickets
touch trip/packing-list.txt trip/days/day-1.txt trip/days/day-2.txt trip/photos/beach.jpg
mkdir -p creates trip and the three folders inside it, and touch creates the four empty files. Neither prints anything.
New-Item -ItemType Directory -Path trip/days, trip/photos, trip/tickets | Out-Null
New-Item -ItemType File -Path trip/packing-list.txt, trip/days/day-1.txt, trip/days/day-2.txt, trip/photos/beach.jpg | Out-Null
The first New-Item creates trip and the three folders inside it, and the second creates the four empty files. | Out-Null hides the details they would print.
Step 2: See Everything find Lists
find trip
trip
trip/tickets
trip/packing-list.txt
trip/days
trip/days/day-1.txt
trip/days/day-2.txt
trip/photos
trip/photos/beach.jpg

Eight lines: trip itself, its three folders, and four files. Each line is a path that starts with the folder you gave. find lists each folder's contents in the order it reads them, not sorted, so your order can differ.
Step 3: List Only the Files with -type f
find trip -type f
trip/packing-list.txt
trip/days/day-1.txt
trip/days/day-2.txt
trip/photos/beach.jpg

Only the four files are left. The folders, including the empty tickets, are gone, but find still went into every folder to find the files inside them.
Step 4: List Only the Folders with -type d
find trip -type d
trip
trip/tickets
trip/days
trip/photos

The opposite list: the four folders. trip is one of them, because the folder you start from is a folder too.
Step 5: Do the Same in PowerShell
Get-ChildItem -Recurse -File -Name trip
packing-list.txt
days/day-1.txt
days/day-2.txt
photos/beach.jpg
Get-ChildItem -Recurse -Directory -Name trip
days
photos
tickets

The same files and folders, with two differences from find. The paths start inside trip, because, in Microsoft's words, The names returned are relative to the value of the Path parameter. And -Directory leaves out trip itself. On Windows, the paths use backslashes, like days\day-1.txt.
Step 6: List the Files of the Folder You're In
Move into trip, then list its files. find gets a ., which means the folder you're in; Get-ChildItem uses that folder when you leave the folder out.
- bash / zsh
- PowerShell
cd trip
find . -type f
./packing-list.txt
./days/day-1.txt
./days/day-2.txt
./photos/beach.jpg
Set-Location trip
Get-ChildItem -Recurse -File -Name
packing-list.txt
days/day-1.txt
days/day-2.txt
photos/beach.jpg

With find, the paths now start with ./, because they start from ..
Step 7: See What Happens When the Folder Isn't There
Go back up to the folder that holds trip, then make a typo, trips instead of trip:
- bash / zsh
- PowerShell
cd ..
find trips -type f
find: trips: No such file or directory
Set-Location ..
Get-ChildItem -Recurse -File -Name trips
Get-ChildItem: Cannot find path '/Users/you/source/find-demo/trips' because it does not exist.

Both name the folder they couldn't find. find also exits with status 1, which tells a script that something went wrong.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
find -type f, without a folder, on macOS | find: illegal option -- t, then a usage line: macOS's find needs a folder to start from | Give a folder: find . -type f |
Expecting -type d to leave out the folder you start from | The starting folder is listed first | Expect it; it's a folder too |
| Expecting the list in alphabetical order | find lists each folder's contents in the order it reads them | Add -s on macOS, as in the FAQ |
FAQ
How do I get the list in alphabetical order?
On macOS, add -s before the folder:
find -s trip -type f
trip/days/day-1.txt
trip/days/day-2.txt
trip/packing-list.txt
trip/photos/beach.jpg
The manual describes -s as: Cause find to traverse the file hierarchies in lexicographical order, i.e., alphabetical order within each directory.
Conclusion
find trip -type f listed only the four files under trip, from every folder inside it, and find trip -type d listed only the folders, trip included. In PowerShell, Get-ChildItem -Recurse -File -Name trip listed the same files, as paths inside trip. Give find a folder, . for the one you're in, and add -s on macOS to sort the list.
Additional Resources
- Get-ChildItem (Microsoft Learn):
-Recurse,-File,-Directoryand-Name. man findin the macOS Terminal: every option offind, including-typeand-s.
