Browse your Tags over a Network with AppleScript and APFS

Hans van de Bruggen
3 min readMar 5, 2018

The tagging feature of Finder is a powerful tool for adding metadata and creating a layer of organization over an arbitrary folder structure. I’ve added tags to much of the content my media center (an old Mac Mini), and it makes it easy to find movies or shows based on their genre, actor, decade, and so on.

Unfortunately, there are some limitations to this. While macOS makes it dead simple to run a search for tags on the local machine, searching a networked machine for tags is nigh impossible. You can create Smart Folders, which are effectively Spotlight searches that can be saved to a folder for convenience, but these don’t show up as browsable folders when connecting over a network. Creating file aliases (or “shortcuts” in Windows land) also has the same effect, as the remote system doesn’t recognize them. Hardly the best choice for a networked media center.

SpotlightFS had promise in the MacFUSE days, as it would dynamically generate “real” read-only folders on-demand by doing a Spotlight search for whatever you specified as the subfolder. It was a little clunky for the purposes of a media center (specifying the path to a non-existent folder is tricky from most TV UIs, for example), and MacFUSE has been abandoned in favor of FUSE for macOS. (SpotlightFS still exists, apparently.)

More recently, Apple launched a new file system called APFS. With APFS, instead of copying a file and occupying twice the disk space, you can clone a file, effectively creating a new reference to the same bits. A lightbulb went off in my head — these are effectively aliases which the filesystem represents as real files. What if you could create folders for each of your tags and clone the tagged files into their folders? Your tags would now be fully network-browsable, and you wouldn’t see an impact on your disk space at all.

Not finding a solution to this already available, I took it upon myself to cobble together an AppleScript to do this for me. I’m by no means a competent programmer (yet?), so despite my no doubt sloppy code, it was much easier to get this working than I’d expected (this says more about AppleScript than it does about me, I’m afraid). The script creates a set of folders for every tag available, clones the appropriate files into the new folders, then cleans up all tag folders for tags not in use on that drive. It also removes all tags from the cloned copies so that you’ll only ever see the original file when searching with Spotlight.

The script has two modes: The first mode, the default, creates a new folder called Tag Folders where it will put all the new folders it creates. The second mode will delete the contents of the chosen folder and replace it with the newly created folders. This is so that you can create a network share with all the sharing permissions set how you like and periodically replace the contents with the latest tagged clones without having to reconfigure anything.

The script is available here for anyone who wants it:

Get Tag Folders AppleScript

--

--

Hans van de Bruggen

Product, Design, and other musings. Author of Learnability Isn’t Enough (book.hansv.com)