# A new tool for Zotero users

**URL:** https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025
**Category:** DEVONthink
**Created:** [December 6, 2020, 1:18am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025 "2020-12-06T01:18:18Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [December 6, 2020, 1:18am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/1 "2020-12-06T01:18:18Z")

</div>

When using [Zotero](https://zotero.org) for reference management, you may on occasion want to work with the PDF files from outside of Zotero. For example, if you’re a [DEVONthink](https://www.devontechnologies.com/apps/devonthink) user, you will at some point discover the power of indexing your local Zotero database from DEVONthink. However, when viewing or manipulating the PDF files from outside of Zotero, you may run into the following problem: when looking at a given PDF file, _how do you find out which Zotero entry it belongs to_?

I developed [Zowie](https://mhucka.github.io/zowie/) (a loose acronym for _“ **Zo** tero link **w** r **i** t **e** r”_, and pronounced like [the interjection](https://www.merriam-webster.com/dictionary/zowie)), an open-source program to help deal with this problem. Zowie scans through the files in a local Zotero database, looks up the Zotero bibliographic record corresponding to each PDF file found, and writes a [Zotero select link](https://forums.zotero.org/discussion/78053/given-the-pdf-file-of-an-article-how-can-you-find-out-its-uri#latest) into the PDF file and/or certain macOS Finder/Spotlight metadata fields (depending on the user’s choice). A Zotero select link has the form `zotero://select/...` and when opened on macOS, causes the Zotero desktop application to open that item in your database. Zowie thus makes it possible to go from a PDF file opened in an application other than Zotero (e.g., DEVONthink, Adobe Acrobat), to the Zotero record corresponding to that PDF file.

In DEVONthink, I index the folder containing my local Zotero database of PDF files. Using Zowie to write the Zotero select link into the Finder comments of every PDF file means that within DEVONthink, the Zotero link will appear in the _Annotations & Reminders_ inspector, in the Finder Comments box. For example:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/b/7/b77a48b48aea4f52164ef2d02bd6d145a9a4358a.png)

The nice thing about having the Zotero select link accessible from DEVONthink is that you can create smart rules to manipulate it further. For example, I use the following smart rule to copy the Zotero select link from the Finder Comments to the “URL” field of each PDF file indexed in DEVONthink:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/0/b/0b3eefd10fa4875339f8ccdb55a9ce1c9c8419fe.png)

where the following is the simple embedded script:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/7/e/7eb1d31faa98fdf5002795a843f6e74347361586.png)

[Zowie](https://mhucka.github.io/zowie/) is written in Python. A ready-to-run executable is available for macOS 10.13–10.14; for macOS versions after 10.14, Zowie needs the user to have a Python 3 environment on their computer. Zowie can be downloaded from the [project home on GitHub](https://github.com/mhucka/zowie), and is also is available [from PyPI](https://pypi.org/project/zowie) for installation via `pip`.

As with all such open-source user-contributed software, there are no guarantees about safety, functionality, or support. I hope it works for you, but I can’t promise that something terrible won’t happen to any of your files, or your computer.

_Update 2020-12-29_: Zowie version 1.1 now processes all files it finds, not just PDF files (because people put more than just PDF files in their Zotero databases). There is a new flag, `-f`, that lets you control which files it acts on. In addition, a self-contained ready-to-run binary is now available for macOS versions 10.13 (High Sierra) and 10.14 (Mojave) – no Python needed! (The binary may or may not run on 10.15 or later, depending on your macOS security settings. I hope to work around that limitation eventually.)

---

<div class="post-metadata">

### Author: ![rmschne](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/r/8baadc/32.png) [@rmschne](https://discourse.devontechnologies.com/u/rmschne)
#### Post date: [December 6, 2020, 7:42am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/2 "2020-12-06T07:42:13Z")

</div>

Happy to give this a try as coincidently, my wife (from son’s input) is interested now in Zotero for her next round of academic paper-writing, and so me (local user support) needs to be interested also. It might be there, but I don’t notice a link to get the code? Github or something?

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [December 6, 2020, 3:17pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/3 "2020-12-06T15:17:07Z")

</div>

Of all the things to forget … yes, you’re right – I forgot to provide a link :-). Will fix right now.

---

<div class="post-metadata">

### Author: ![rpallred](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/rpallred/32/18214_2.png) [@rpallred](https://discourse.devontechnologies.com/u/rpallred)
#### Post date: [January 10, 2021, 2:06am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/4 "2021-01-10T02:06:55Z")

</div>

I had missed this part of the zowie work flow–this smart rule is groundbreaking for me. Thanks!

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [January 10, 2021, 5:06am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/5 "2021-01-10T05:06:42Z")

</div>

For people who are using the Smart Rule above: if you don’t have a scheme for running [Zowie](https://mhucka.github.io) on your Zotero files when you add new items to your Zotero database, then new items won’t trigger the Smart Rule simply because they won’t have the Zotero link in the Finder comments. One way to solve this is to use another Smart Rule in DEVONthink that is triggered when new items are imported, and if they lack the Zotero select link, run Zowie on them.

Here’s the Smart Rule I use for that:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/e/0/e006ae23b1feb0d7fd9d7eefc8cc7d30da458934.png)

and here’s the embedded AppleScript used in the rule:

```applescript
on performSmartRule(selectedRecords)
	repeat with _record in selectedRecords
		set p to the path of the _record
		set result to do shell script "/usr/local/bin/zowie -q '" & p & "'"
		if result is not equal to "" then
			display notification result
		end if
	end repeat
end performSmartRule

```

Make sure to update the path to Zowie in the script above if it is not `/usr/local/bin/zowie`.

The latest version of this script will be [available on GitHub](https://github.com/mhucka/devonthink-hacks/blob/main/zowie-scripts/Run%20Zowie%20on%20newly%20indexed%20PDF.applescript).

---

<div class="post-metadata">

### Author: ![rpallred](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/rpallred/32/18214_2.png) [@rpallred](https://discourse.devontechnologies.com/u/rpallred)
#### Post date: [January 10, 2021, 6:24pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/6 "2021-01-10T18:24:04Z")

</div>

I’m still getting used to the power of smart rules… I had set up a Hazel rule to do something similar:

 ![Screen Shot 2021-01-10 at 10.17.39 AM](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/c/b/cbf8d56102146102413d2b0d57ad5f3f11f833ab.jpeg)

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [January 10, 2021, 6:55pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/7 "2021-01-10T18:55:33Z")

</div>

Oh, that’s a good idea too!

---

<div class="post-metadata">

### Author: ![lutefish](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/l/958977/32.png) [@lutefish](https://discourse.devontechnologies.com/u/lutefish)
#### Post date: [January 11, 2021, 7:05pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/8 "2021-01-11T19:05:57Z")

</div>

This looks great, though I have a question about how it handles Zotero libraries that link to files stored elsewhere? Everything in my Zotero library is stored on cloud-synced [Box.com](http://Box.com) finder folders, which are then indexed in DT. As there are no PDF files in the ~/Zotero/storage folders, only .zotero-ft-cache and .zotero-ft-info files, how does the script handle this?

---

<div class="post-metadata">

### Author: ![rpallred](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/rpallred/32/18214_2.png) [@rpallred](https://discourse.devontechnologies.com/u/rpallred)
#### Post date: [January 11, 2021, 7:39pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/9 "2021-01-11T19:39:13Z")

</div>

So I’m not familiar with how [Box.com](http://Box.com) works, but if it has a Finder location, you should be just fine. If I’m reading the [this help article](https://support.box.com/hc/en-us/articles/360043697454-Configuring-the-Default-Box-Drive-Folder-Location) correctly, simply point zowie to the correct location:

`zowie -f pdf /Users/GWashington/Box/FolderWhereIKeepTheFiles`

That’s actually how the Hazel rule works–Hazel is watching the entire folder and all subfolders. When it detects a match (say, because I just added a new journal article to by Zotero database), it passes the full URL of that PDF in the variable $1 to zowie, which then runs just on that one file (it would be really inefficient to do it this way if it’s the first time ever that zowie has run on a folder!).

---

<div class="post-metadata">

### Author: ![lutefish](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/l/958977/32.png) [@lutefish](https://discourse.devontechnologies.com/u/lutefish)
#### Post date: [January 11, 2021, 7:58pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/10 "2021-01-11T19:58:43Z")

</div>

Thanks. I’m hitting some other errors with Zowie (tuple index out of range), but can take it up on GitHub.

---

<div class="post-metadata">

### Author: ![npfet](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@npfet](https://discourse.devontechnologies.com/u/npfet)
#### Post date: [January 26, 2021, 5:13pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/11 "2021-01-26T17:13:31Z")

</div>

A quick question on DT \<-\> Zotero integration: Is there a way for DT to ignore the subfolder layout when indexing Zotero’s storage folder, and to ignore file types that aren’t desired (e.g. only index PDF’s)?

If I index the storage folder directly, I get the Zotero link identifier folders and lots of .js files stored as part of online web abstracts. I could use ZotFile, but that has some additional complexity with storing attachments outside of the storage directory, since then I will not be able to sync with my work laptop.

---

<div class="post-metadata">

### Author: ![rpallred](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/rpallred/32/18214_2.png) [@rpallred](https://discourse.devontechnologies.com/u/rpallred)
#### Post date: [January 26, 2021, 5:28pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/12 "2021-01-26T17:28:34Z")

</div>

I am wondering the same thing–I created a smart group of my Zotero PDFs as a stopgap.

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [January 27, 2021, 3:29am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/13 "2021-01-27T03:29:44Z")

</div>

That is a good question! To my knowledge, there is no way to directly control DEVONthink’s indexing mechanism and get it to ignore certain file types. However, one can resort to using a smart folder. Here’s how I do it, as an example to get you started.

I have a top-level folder in my database called `Sources`. Within that, I have a folder called `Zotero` and within _that_, I put the actual indexed folder. (The reason for this indirection is purely aesthetic: I index the `storage` folder inside my Zotero database folder, since that’s where Zotero stores PDFs, but I find the name `storage` confusing in the context of the rest of my folder structure in DEVONthink. The indexed folder cannot be renamed in DEVONthink because it matches whatever’s on disk, so the only option left is to create another folder in DEVONthink and call that one whatever I want.)

![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/8/d/8d3f3313e1a4cb1149f5e3559bcb03797fec6870.png)

WIthin the folder `Sources`, I put a smart folder that searches inside the `storage` folder. Here’s its definition:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/7/6/7623e6ec6b397a97ebac692d879fe21f4f8e3691.jpeg)

I’m not convinced this particular smart folder definition is ideal; for one thing, if I ever put another file type into my Zotero database, I have to remember to update the smart folder definition to include it. But it’s good enough for now, and it avoids all those css, js, and other files that may end up in a Zotero folder. It produces a very clean list of articles:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/c/c/cc76a0b1ab247650c47b4007490919f1ab93b954.png)

Hope this helps!

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [January 27, 2021, 6:36am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/14 "2021-01-27T06:36:52Z")

</div>

No you can’t control DEVONthink’s indexing and exclude items from being indexed.

---

<div class="post-metadata">

### Author: ![npfet](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@npfet](https://discourse.devontechnologies.com/u/npfet)
#### Post date: [January 28, 2021, 4:15am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/15 "2021-01-28T04:15:01Z")

</div>

> [@mhucka](#):
>
> I’m not convinced this particular smart folder definition is ideal; for one thing, if I ever put another file type into my Zotero database, I have to remember to update the smart folder definition to include it. But it’s good enough for now, and it avoids all those css, js, and other files that may end up in a Zotero folder. It produces a very clean list of articles:

Thanks! Good to understand how you have that setup.

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [June 26, 2021, 6:06pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/16 "2021-06-26T18:06:52Z")

</div>

For anyone using this approach, I wanted to alert you that I recently updated the embedded AppleScript mentioned above in order to deal with some problems with special characters in file names. The latest version is [available on GitHub](https://github.com/mhucka/devonthink-hacks/blob/main/zowie-scripts/Run%20Zowie%20on%20newly%20indexed%20PDF.applescript) and here it is for convenience:

```auto
# The following function is based on code posted by user "mb21" on
# 2016-06-26 at https://stackoverflow.com/a/38042023/743730

on substituted(search_string, replacement_string, this_text)
	set AppleScript's text item delimiters to the search_string
	set the item_list to every text item of this_text
	set AppleScript's text item delimiters to the replacement_string
	set this_text to the item_list as string
	set AppleScript's text item delimiters to ""
	return this_text
end substituted

on performSmartRule(selectedRecords)
	repeat with _record in selectedRecords
		# In my environment, Zotero takes time to upload a newly-added
		# PDF to the cloud. The following delay is needed to give time
		# for the upload to take place, so that when Zowie runs and
		# queries Zotero via the network API, the data will be there.
		delay 30

		set raw_path to the path of the _record

		# Some chars in file names are problematic due to having special
		# meanings in shell command strings. Need to quote them with 2
		# blackslashes, b/c the 1st backslash will be removed when the
		# shell command string is handed to the shell.
		set sanitized_path to substituted("&", "\\\\&", raw_path)

		# Another problem with file names is embedded single quotes. The
		# combination of changing the text delimiter and using the
		# AppleScript "quoted form of" below, seems to do the trick.
		set AppleScript's text item delimiters to "\\\\"
		set result to do shell script ¬
			"/usr/local/bin/zowie -q " & (quoted form of sanitized_path)

		# Display a DEVONthink notification if an error occurred.
		if result is not equal to "" then
			display notification result
		end if
	end repeat
end performSmartRule

```

---

<div class="post-metadata">

### Author: ![NationalInterest](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@NationalInterest](https://discourse.devontechnologies.com/u/NationalInterest)
#### Post date: [September 24, 2021, 2:58pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/17 "2021-09-24T14:58:49Z")

</div>

Thanks for this application! Works great (once I downgraded sidetrack as you suggested on Github). I’m trying to make Zotero my central source of wisdom for information sources I find, be it websites, articles or books. This lets it be so!

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [September 24, 2021, 3:20pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/18 "2021-09-24T15:20:44Z")

</div>

Welcome @NationalInterest

I’m sure @mhucka appreciates the pat on the back! 🙂

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [October 25, 2021, 1:06am UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/19 "2021-10-25T01:06:21Z")

</div>

In case anyone is interested, I’ve released a new version of Zowie (1.2.0) that fixes a software compatibility issue, adds a new feature that will be of interest to DEVONthink users, has faster startup time, and comes with single-file self-contained runnable binaries for macOS 10.15 and higher. See [https://mhucka.github.io/zowie/](https://mhucka.github.io/zowie/).

---

<div class="post-metadata">

### Author: ![mhucka](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mhucka/32/28691_2.png) [@mhucka](https://discourse.devontechnologies.com/u/mhucka)
#### Post date: [October 29, 2021, 4:35pm UTC](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025/20 "2021-10-29T16:35:28Z")

</div>

Another note for anyone using Zowie for Zotero: I wrote an [explanation of my smart rule scheme](https://github.com/mhucka/zowie/wiki/Example:-using-Zowie-with-DEVONthink) in a wiki page associated with the GitHub repository.

[Next page](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025.md?page=2)
