How do I list all folders and subfolders alphabetically on my MacBook Air?

I would like to see a list of all my folders and subfolders, alphabetically

The folders are in the Documents folder


[Re-Titled by Moderator]

MacBook Air (M3, 2024)

Posted on Oct 26, 2024 5:04 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 26, 2024 6:07 AM

Launch the Terminal application. At the command prompt, enter the following commands that will write a text file to your Desktop that contains the alphabetical folder hierarchy of your Documents folder to the Desktop. The (/:on) syntax says only folders and sorted ascending by name. The '**' means recursively descend into the folder hierarchy.


cd
for f in ~/Documents/**/*(/:on); do print -Dl "${f}"; done > ~/Desktop/documents_folder.txt


That will take about a second or two and the text file on your Desktop can be viewed with Quick Look or opened in a Text editor.

Similar questions

11 replies
Question marked as Top-ranking reply

Oct 26, 2024 6:07 AM in response to Bomiboll

Launch the Terminal application. At the command prompt, enter the following commands that will write a text file to your Desktop that contains the alphabetical folder hierarchy of your Documents folder to the Desktop. The (/:on) syntax says only folders and sorted ascending by name. The '**' means recursively descend into the folder hierarchy.


cd
for f in ~/Documents/**/*(/:on); do print -Dl "${f}"; done > ~/Desktop/documents_folder.txt


That will take about a second or two and the text file on your Desktop can be viewed with Quick Look or opened in a Text editor.

Oct 26, 2024 1:58 PM in response to Bomiboll

To get a sorted list In Print Window 5, under the File Information tab, select:

  • Sort by -> Name
  • Sort Order > Ascending



And if you want only folder names (nothing else), you should probably also:

  • Select Layout > Expand all Folders
  • Select File Information > Name (uncheck Kind, Size, etc.)
  • Deselect Icons & Headers > Include Heading
  • Deselect Icons & Headers > Include Icons


There are quite a few options in the various tabs & pull downs in PW5. Take a look through them.


Alternatively, you can export to CSV or Excel and then sort the file names in Excel, Numbers or other apps.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I list all folders and subfolders alphabetically on my MacBook Air?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.