Scrivener is a great tool for writing, especially if you’re like me and you like to chunk out your thoughts so that you can rearrange them later. Scrivener also has a very nice ‘research’ folder, into which you can copy out your notes a la one-thought-one-card, and then drag them into the actual writing as necessary.
Tropy is a new offering from the Roy Rosenzweig Center for History and New Media at George Mason University. It lets you manage your research photographs, such that you can annotate them, transcribe the text (say you’re in an archive taking pics of historical documents), or otherwise mark them up. I recently thought to myself, facing a stack of short-term loan books I’d accumulated, maybe I can take pictures of the bits here that I’m interested in, and use Tropy to sort them out. (I took the pics with my phone, saving them to my google drive which then synced to this computer where Tropy was waiting).
Then I wondered, perhaps I can export the notes such that they update in Scrivener as unique cards? Now, I know that Tropy has a sqlite database in the back end, and presumably I could’ve written some sort of query that’d do all of what I’m about to lay out. But I don’t know how to do that sort of thing. So instead, I’m using jq (see this tutorial) to do the heavy lifting, and a few other commands at the terminal.
1. So make your notes in Tropy. Highlight your images, and select ‘export’. Tropy exports in json-ld which is a bit different than regular ol’ json.
2. I’m on a Mac. Open terminal at the folder where you’re working. We’ll want to remove the top level [ and ], like so:
sed -i.bak 's|\[||' export.jsonld sed -i.bak 's|\]||' export.jsonld
3. Now we’re going to use the jq command (which you can install with homebrew) to get the notes out. This will do the trick:
.["@graph"][].photo[] | {id: .title, note: .note.html}
So the full jq command in the terminal is:
jq -r '.["@graph"][].photo[] | {id: .title, note: .note.html}' export.jsonld > out.txt
4. Now we’re going to split that out.txt file into separate files. Don’t do it yet, but the command will look like this:
split -p ^{ out.txt new
Let’s make a new folder for the split-up notes that we will then import into Scrivener.
mkdir outputnotes cd outputnotes
5. Let’s split that out.txt file and have the output written into our current directory:
split -p ^{ ../out.txt
6. Scrivener is probably smart enough to recognize text, even without an extension, but just in case, let’s pretend these things are in markdown. Maybe you actually wrote your notes in markdown in the first place.
for f in *; do mv "$f" "$f.md"; done
7. And so, over in Scrivener, just import this folder!
Or, if you want to use scrivener sync (say you’re collaborating): in scrivener sync settings, make a new folder. Do the jq step, then cd into the new folder (here, ‘scrivtest’). Inside that new folder,
mkdir Notes cd Notes split -p ^{ ../../out.txt
You don’t want to be in the Draft folder that scrivener made. Give those files the md extension as before. Now go over to scrivener and hit sync. make sure to tick off the option to sync all other text objets to the project. Ta da! your notes are now in your research folder!
I’m sure this can probably be streamlined, but not bad for an hour’s futzing.
You must be logged in to post a comment.