Creating an html file list of an archive

18 Jan 2023

We recommend our clients use a Production -> Nearline -> Archive workflow.  Production data is synced to Nearline (full copy nightly, syncs every hour).  Then when projects are complete, data is sent to duplicate tapes and cloud storage.  While people can view and search archives in the cloud or the Archiware P5 web interface, often they like to navigate in the file system they are used to.  Continue reading to see how we solved this problem.

Once a project is archived to tape and the cloud, we run a script to create a tree of all the files in the project and save it into an html file.   The script needs 2 arguments, the root folder of the project and where to save the html output.  These can be passed to the script as arguments, i.e. ProjectToHTML.sh /path/to/project /path/to/destination/, or the script will prompt the user via AppleScript if both arguments aren’t provided or the paths don’t exist.  

We start creating the html file based on the project folder’s name.  Then the scripts looks for a file call <blah>_info.txt.  This is a convention used by some of our customers to give a brief overview of the project.  If this exists, the contents of the file are written to the html file as well.

Now we get to creating the file list.  We use the tree tool from Steve Baker (http://mama.indstate.edu/users/ice/tree/) and ask it to output json.  Tree is available from Brew, but is also easy to build on your own.  The json output is saved to a file in /tmp/ and has one line per file or directory recursively in the project folder.

The json is parsed and each directory creates a collapsable line in the html using the detail/summary html construction and each file is entered within the appropriate section.   The html file is saved as <projectname>_info.html in the provided destination folder.

The script is available on our GitHub.

Share

Eric Hemmeter