Tom Lauck’s

Print File Structure In Mac OS X


The topic arouse while working a large project: “How can I print the directory structure in OS X? It was easy in OS 9.”

It is possible by using the Terminal application. I intend to write an AppleScript in the near future to do this automatically.

Open up Terminal (Its located in the Utilities folder in Applications)Enter


*Make Sure there is a space after ‘cd

Select or open a finder window that has the directory of interest. Drag the file to the Terminal window and hit Enter.

A new line should appear. Type:

ls -RF > ~/Desktop/file_structure.txt

Look at your Desktop. A file named ‘folder_list.txt’ should be visible. You can now edit and do with it what you wish. is the name of the file you want the output of the recursive ls command to write out to. Feel free to use something more descriptive as you wish.

9 Responses

date: November 6th, 2007

using os leopard. Instructions above did not work.

spoken by: adam

date: December 16th, 2007

very interesting, but I don’t agree with you

spoken by: Idetrorce

date: October 19th, 2008

Leopard works. The directions could be a little clearer for someone not familar with command line but great solve – thanks.

Is there a way to limit the recursive ? For example I only want it to go down two directory levels …

spoken by: JJWombat

date: March 23rd, 2009

find ./ -maxdepth 2 -type d -print > directory.txt

Will do it for you, you’ll get all the dot files (normally hidden) to.\

Change ./ to the starting directory you want to list. -maxdepth 2 should be pretty obvious.

spoken by: Troy

date: June 13th, 2010

Nice article.

Also, liking the blog design. I had a similar designed blog myself before I sold it on.

spoken by: Dawna Bluitt

date: January 18th, 2011

Just wanted to thank you. Very helpful!

spoken by: Jonah

date: February 17th, 2012

Appreciate the fresh look. I were pleased with the information. Credit for this fantastic page.

spoken by: Karon

date: May 8th, 2014

Hi Tom,

Thanks for the explanation. Did you in the end write a script to do this?

That would be a time saver.



spoken by: Marcel

date: August 22nd, 2014

This is great! Is there a way to put the directory structure in a indexed look?

for example?

spoken by: Bill

Leave a Reply

Feb 14 2007