How to List All Files and Subdirectory Contents in a Folder on Mac

Jan 29, 2013 - 8 Comments


Ever wanted to see not only every file in a given directory, but all files within that directories buried subdirectories? If you’re looking for what is basically a recursive listing of files in a given folder, we’ll show a great trick for the Mac OS Finder that allows you to do just that, and also demonstrate several more advanced approaches using the command line.

How to Expand All Subdirectories & List Folder Contents in the Mac OS Finder

To quickly see what’s in all the subdirectories of a folder within the Finder, open the parent folder and change to list view. Now you need to hold the Option key and click on the little arrow alongside the name of the directory to expand that directory and all subdirectories at the same time.

Expand subfolders in OS X Finder

The result is that each and every subfolder contained within the directory you option-clicked the arrow on will reveal its contents as well:

Recursive directory listings in Mac OS X

Option-clicking that arrow again will cause all subdirectories to close up, otherwise that becomes the new default view when clicking the arrow.

Keep in mind that if you want to view hidden files through this method, you must enable hidden files to be shown in the Mac OS X Finder separately, which will then carry out through every folder until it is disabled again.

The above approach is going to be the easiest method for most users, and the next two methods are focused on the command line and are aimed at those comfortable in the Terminal.

List All Files & Subdirectory Contents from the Command Line

To list all files recursively from the command line, you can attach the -R flag to the traditional ls command. This expands out subdirectories and lists the files contained within them. These commands will work in just about all forms of unix, from Mac OS X to Linux or whatever else you may encounter.

ls -R ~/Desktop/

Sample output would look something like this:

Dark Tower.jpg milky-way.jpg
car.jpg ngc602.jpg
flaming-star-nebula.jpg ngc6188Kfir2000.jpg
windows.jpg m33.jpg
volcano.jpeg itenerary.txt tickets.JPG

The output is decent, but it could be arranged better.

Using the -lah flags in addition to -R will show permissions, ownership, modification dates, and it makes reading file information much easier. The -a flag is optional, allowing hidden files to be displayed as well.

ls -lahR ~/Desktop/

Sample output would look like:

total 5464
drwxr-xr-x@ 11 macuser staff 374B Jan 14 15:32 .
drwxr-xr-x 522 macuser staff 17K Jan 28 10:20 ..
-rw-r--r--@ 1 macuser staff 254K Jan 13 15:44 Dark Tower.jpg
-rw-r--r--@ 1 macuser staff 101K Jan 14 15:32 cars.jpg
-rw-r--r--@ 1 macuser staff 141K Jan 13 15:44 star-nebula.jpg
-rw-r--r--@ 1 macuser staff 206K Jan 14 09:57 nintendo.jpg
-rw-r--r--@ 1 macuser staff 134K Jan 13 15:44 m33.jpg
-rw-r--r--@ 1 macuser staff 1.4M Jan 13 15:30 milky-way.jpg
-rw-r--r--@ 1 macuser staff 153K Jan 13 15:44 ngc602.jpg
-rw-r--r--@ 1 macuser staff 194K Jan 13 15:44 windows.jpg
total 360
drwxr-xr-x@ 6 macuser staff 204B Dec 9 13:43 .
drwxr-xr-x 522 macuser staff 17K Jan 22 10:20 ..
-rw-r--r--@ 1 macuser staff 6.0K Dec 9 13:43 .DS_Store
-rw-r--r--@ 1 macuser staff 30K Dec 8 12:41 volcano.jpeg
-rw-r--r--@ 1 macuser staff 45K Dec 8 12:41 itinerary.txt
-rw-r--r--@ 1 macuser staff 88K Dec 9 12:31 tickets.JPG

You’ll notice the path to each file is listed above the files themselves, expanding out the subdirectories a lot like the Finder method mentioned up top. You can get the path to proceed the file name though by using a different command entirely.

List All Files Recursively with Full Directory Paths Shown

Finally, if you want a list of all files with their complete paths specified, you can turn to the find command.

find ~/Desktop/Sample/ -type f

This will dump the full path to each file in a listing:


If you’re looking to share a directory listing with someone, the find command likely offers superior results. In such a case, you can dump the output to a file easily by attaching a > to the end like so:

find /Path/To/List -type f > FilesWithPaths.txt

The “-type f” flag signifies regular files only, if you want to show more objects or symbolic links you can check out the man page for find for additional information.


Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. Rodrigo says:


  2. Ken says:

    The first example (Finder) still shows the files in their subdirectories. I’d like to just get a list of files, then click on “Date modified” to find recent activity. Is this possible in Finder, or am I stuck with command line “find . -mtime ###” ?

  3. Joe Contreras says:

    How can you run this command and display the file attributes as well? That will be incredibly helpful

  4. sowmya says:

    Very Useful ..Thanks

  5. mackie8i says:

    not working for me..

    i change to list view .. holding option and i don’t see the arrow from the left comes up..

  6. Alberto says:

    How to open with one click all the folder in one directory, just clicking on the little triangle of one folder?

    If I remember well it was possible with System 9 with option click.
    And now with OsX it seems that this possibility has disappeared :(

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site