Created
August 8, 2021 21:44
-
-
Save KalebNyquist/2ca3ac322751578b6d791cd90b4df15b to your computer and use it in GitHub Desktop.
One of my frustrations with Zotero is that there is no easy way to list all the collections in which a file is stored. This is my band-aid of a solution. The code can be run under Tools > Developer > Run Javascript using "Sync" mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instructions: | |
// (1) Highlight file of interest. | |
// (2) Run code in Zotero's JavaScript console (found under Tools > Developer > Run Javascript) in sync mode. | |
function collections_output() { | |
zp = Zotero.getActiveZoteroPane() | |
items = zp.getSelectedItems() | |
collection_ids = items[0]["_collections"] | |
collections_cache = Zotero.Collections._objectCache | |
return_string = items[0]["_displayTitle"] | |
return_string += "\n\nCollections: \n" | |
for (i = 0; i < collection_ids.length; i++) { | |
return_string += "(" | |
return_string += i+1 | |
return_string += ") " | |
return_string += collections_cache[collection_ids[i]]["name"] | |
if (i + 1 != collection_ids.length) { | |
return_string += "\n" | |
} | |
} | |
return return_string | |
} | |
collections_output() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, thank you!