Print a Hierarchical List of Disk Contents

VFX companies often include paper printouts of a hard drive’s contents when they send material to/from Production, the DI, and other vendors. Occasionally, it’s useful for Editorial departments to do the same. Having a printout attached to a hard drive you’re sending out lets your vendor see exactly what’s on the drive without having to plug it in, and can be used to log a drive in or catalog it while it’s offline.

Strangely, there’s a lack of software available to do such a simple task as printing a directory listing. Searching through Google, I found a few applications for OSX that offered this functionality, but either the application wasn’t exaclty what I was looking for, or it added too many flourishes like icons and such.

So, I turned to the Terminal. Using a pattern I found in a forum on, I modified the arguments and incorporated it into an Automator workflow (attached). This workflow displays a recursive list of directories (if you want only files or both files and directories see the bottom of this post), and is broken into the following steps:

  1. Asks for the root folder you’d like to make a listing from. This would usually be the root of your external hard drive.
  2. Asks how many levels of recursion you’d like.
    • Example: In one instance I was backing up P2 cards. I only needed to list the folder name of each P2 card I was including, and not the CONTENTS, VIDEO, VOICE, PROXY, ICON, and AUDIO folders that exist as subfolders of a P2 card’s root directory. So using this function with a recursion level of 2, my printout stopped processing directories after 2 levels of hierarchy.
  3. Runs the shell command:
find "$2" -type d -maxdepth $1 ! -name '.*' -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<2  && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}'  FS='/'
  1. Saves a text file with the listing in the same directory you chose in Step 1, and then opens that file so you can browse and print it.

The output looks like this:

|      |---Warrior Back Up
|      |              |---Dailies by Tape
|      |              |              |---CT001
|      |              |              |---HI-8
|      |              |              |---VT001
|      |              |              |---VT002
|      |              |              |---VT003
|      |              |              |---VT004
|      |              |              |---VT005
|      |              |              |---VT006
|      |              |              |---VT007
|      |              |              |---VT008
|      |              |              |---VT009
|      |              |---P2 Backup
|      |              |        |---MISC
|      |              |        |---PRODUCTION
|      |              |        |---REHEARSAL FIGHTS
|      |              |        |---TESTS

Future Refinements

Suggestions welcome, but things I'm already thinking to add to this workflow later on are:

  1. An option to show files as well as folders. You can change this in the workflow yourself by changing "-type d" to "-type f" for a files-only listing, or remove "-type d" completely for both files and folders.
  2. A dialogue to ask if you want to print the listing automatically

Next Article

Upres a Sequence Multiple Times

Feature films often screen preview versions a couple of times before the final picture lock. With the ease-of-use and "projectability" of DNxHD 115 and above, many Editorial crews are opting to do their own onlines. This article explains a simple workflow if you have to online multiple times.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. Do you know how to do this with Apache Server, Linux OS?

  2. I think that same command should work, you’d just want to replace $2 with the path you want to search from, and $1 with the number of levels of recursion. Then pipe it into a text file or whatever else you need.

  3. I think this is a great tool. Is there anyway that this could possibly be listed into an Excel document, with specific headings for certain columns? I’m not a scripting genius, just trying to see if maybe there is a way to do this since we use Excel a lot of databasing HDD contents. Thanks for this BTW!

  4. There’s probably an application you can pay for that would make an Excel file of this more elegantly, but to use this Terminal command you’d probably have to alter it make a comma-separated values file, and even then I’m not sure what the best way would be to organize it. The column headings would probably just be something like root, subdirectory1, subdirectory2, and that could make for a pretty confusing layout.

  5. Thanks! I found your command useful for Cygwin on Windows too. 🙂

    find . | awk ‘!/\.$/ {for (i=0; i<NF; i++) printf("%*s",5,"|")} {print $NF;}' FS='/'