List an OS X folder hierarchy with TextWrangler

If you need to get a structured list of the directories in a folder, TextWrangler can do that.

The OS X Finder is a great tool to use for organizing your documents and projects into folder hierarchies; however, it is a bit limited. If you would like to save this hierarchy as a list in a file then the Finder and OS X does not provide these options. While the Finder does support printing a folder's listings by dragging a folder to a print queue, this is about the limit of the options for listing folder items.

One alternative to this is to use screenshots; however, these are static images in which items cannot be selected and copied, or otherwise managed.

Another alternative is to try using Automator, AppleScript, or shell scripts (including tools like "tree" to list hierarchies) to construct a workflow for this purpose; however, this can sometimes take a bit of development and testing, and be a daunting task especially for those who are not familiar with scripting languages.

Folder lines in TextWrangler
The folder lines in TextWrangler all contain a colon symbol, which can be used to extract them to a new document. Screenshot by Topher Kessler/CNET

Despite this, an easier option does exist with the free TextWrangler utility that is available for OS X from BareBones Software. One feature that TextWrangler supports is the ability to create a tab-indented hierarchical tree of a folder's contents and display it in a text document by simply dragging a folder to a document's window. However, this feature will include all files and folders in the hierarchy, which may sometimes not be wanted.

If you are only interested in showing the folders in a directory structure and no files, then you can still do this by taking advantage of how TextWrangler manages folder notation in its directory listing feature.

In OS X the folder separator symbol is a forward slash; however, this is a change from the classic Mac OS in which the folder separator was a colon. Nevertheless, OS X still recognizes the colon as a reserved symbol and will not by default allow it to be used in file names. However, in its directory listing feature, TextWrangler will use a colon to separate folders.

Since you are guaranteed for the most part that folder paths in TextWrangler will have a colon and file listings under these will not, you can use this difference to extract lines from a folder listing to only get a listing of the directories in a tree, instead of all files. To do this, run the following steps:

TextWrangler folder list
When finished, TextWrangler's new document will have only the hierarchy of folders shown. Screenshot by Topher Kessler/CNET
  1. Launch TextWrangler and drag a desired folder to the blank document window.
  2. Select "Process Lines Containing" from the Text menu.
  3. Enter a single colon symbol in the "Find Lines Containing" field, and check the option to copy to a new document.
  4. Click the Process button.

With these steps run, TextWrangler will create a new document containing only the folder hierarchy tree for your desired Finder folder.

Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

Featured Video

Stop your Vizio smart TV from spying on you

CNET's Dan Graziano shows you how to disable Vizio's data collecting feature on your smart TV.

by Dan Graziano