---
title: 'bookmark-cli: OS X bookmark data for scripters'
date: 2014-07-07 08:00
slug: bookmark-cli-os-x-bookmark-data-for-scripters
categories:
- Code
tags:
- cli
- macos
- tagging
---

[gh]: https://github.com/ttscoff/bookmark-cli
[losetags]: http://brettterpstra.com/2014/07/04/how-to-lose-your-tags/

![](https://brettterpstra.com/uploads/2014/07/bookmark-icon.png)

I've been working on a simple solution for [backing up and restoring OS X tags][losetags] after catastrophes. Ultimately this is going to have to be more than a script, but I have most of the pieces in place. As part of the experiment I wanted to be able to handle files being renamed and moved. That's best handled by the file [bookmarking portions of the Cocoa API](https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/AccessingFilesandDirectories/AccessingFilesandDirectories.html#//apple_ref/doc/uid/TP40010672-CH3-SW10), so I wrote a little CLI to capture and restore bookmark data for a file or folder.

It's very rudimentary, but it doesn't need to do much more than it already does. You pass a file path to the `save` command and it returns a base64-encoded string that you can store however you like. Pass that string back to the `find` command and it will tell you where the file is, even if it's been renamed or moved.

	$ BOOKMARK=$(bookmark save filename.ext)
	$ mv filename.ext filename-2.ext
	$ bookmark find $BOOKMARK
	=> filename-2.ext

This is really handy on your local filesystem. Unfortunately, it doesn't do diddly squat if you move the file to an external drive, network drive, or send it through certain sync services. I have those cases mostly covered in my tag backup tool, which I'll post when it's ready. This little tool was built as a handy helper and not something for a script to rely entirely upon.

The source is [on GitHub][gh] if you want to compile it yourself. The download below is a binary that _should_ be usable on any 10.8+ Mac. Let me know if you have issues.

**[Download bookmark-cli v1](https://brettterpstra.com/downloads/bookmark-cli1.0.zip)**

CLI for storing Cocoa bookmark data for a file from scripts and the command line

[More info](https://brettterpstra.com/2014/07/05/bookmark-cli)

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
