Automatically Import new Papers From Zotero to Obsidian

Hey guys,

I was wondering if anybody has an option for the Obsidian Zotero Plugin that automatically retrieves new Items addes to my libraries. Everytime I am working on a paper I forget to update it in Obsidian and by the time I remember to update a paper I dont know which one so I need to import my whole library again which is a bit frustrating as it takes quite an amount of time so if everybody has a script or something to do that automatically that would be great :slight_smile:

Hi @Bulgy404,

If you’ve set Better Bibtex to automatically export your Zotero library or a collection, this script can automatically import (or in the case of existing literature notes, update) all the papers in the exported BibTeX file. Note: It requires the Zotero Integration plugin.

I would run the script using Quickadd. You can add it to a macro, and set the macro to run on plugin-load, everytime Obsidian opens.

1 Like

Hey @Feralflora

Thanks for the script :slight_smile:

I configured it so run on sart and it also seems to import the papers but even after some time nothing is getting updated.

I mean it would be really helpful to have at least the new papers directly displayed in obsidian but unfortunately it doesnt reload all papers with the annotations because I am using this template, which is helpful by sorting different colored annotations:


tags: [{{allTags}}]
title: “{{title}}”
authors: “{{authors}}”
year: {{date | format(“YYYY”)}}
publisher: “{{publicationTitle}}”
citekey: {{citekey}}
collection: “[[{{collections[0].fullPath}}]]”


[!meta]- Metadata
abstract:: {{abstractNote}}
zotero_link:: {{pdfZoteroLink}}
Related:: {% for relation in relations -%} {%- if relation.citekey -%} [[{{relation.citekey}}]], {% endif -%} {%- endfor%}
url:: {{url}}
doi:: {{doi}}
bibliography:: {{bibliography}}


Webpage


Self Notes

{% persist “notes” %}

{% endpersist %}


Reading notes

{%-

set zoteroColors = {

“#2ea8e5”: “blue”,

“#5fb236”: “green”,

“#a28ae5”: “purple”,

“#ff6666”: “red”,

“#ffd400”: “yellow”,

“#f19837”: “orange”,

“#aaaaaa”: “grey”,

“#e56eee”: “magenta”

}

-%}

{%-

set colorHeading = {

“blue”: “:information_source: Background information, Prerequisites”,

“green”: “:question: Assumptions, Questions, Goals, Problems”,

“purple”: “:bar_chart: Main findings, Results, Conclusions”,

“red”: “:test_tube:Experimental details or Methods”,

“yellow”: “:star: Interesting point, Facts, Examples”,

“orange”: “:warning: Discussion, Disagree with author”,

“grey”: “:date: Vocabulary, Names, Dates, Definitions”,

“magenta”: “:page_facing_up: Important references”

}

-%}

{%- macro calloutHeader(type) -%}

{%- switch type -%}

{%- case “highlight” -%}

Highlight

{%- case “image” -%}

Image

{%- default -%}

Note

{%- endswitch -%}

{%- endmacro %}

{%- set newAnnotations = -%}

{% if annotations.length > 0 %}

{%- for annot in annotations -%}

{%- if annot.color in zoteroColors -%}

{%- set customColor = zoteroColors[annot.color] -%}

{%- elif annot.colorCategory|lower in colorHeading -%}

{%- set customColor = annot.colorCategory|lower -%}

{%- else -%}

{%- set customColor = “other” -%}

{%- endif -%}

{%- set newAnnotations = (newAnnotations.push({“annotation”: annot, “customColor”: customColor}), newAnnotations) -%}

{%- endfor -%}

{#- INSERT ANNOTATIONS -#}

{#- Loops through each of the available colors and only inserts matching annotations -#}

{#- This is a workaround for inserting categories in a predefined order (instead of using groupby & the order in which they appear in the PDF) -#}

{%- for color, heading in colorHeading -%}

{%- for entry in newAnnotations | filterby (“customColor”, “startswith”, color) -%}

{%- set annot = entry.annotation -%}

{%- if entry and loop.first %}

[[{{colorHeading[color]}}]]

{%- endif %}

[!quote{{“|” + color if color != “other”}}]+ {{calloutHeader(annot.type)}} (page. {{annot.pageLabel}})

{%- if annot.annotatedText %}

{{annot.annotatedText|nl2br}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}

{%- endif %}

{%- if annot.imageRelativePath %}

![[{{annot.imageRelativePath}}]]

{%- endif %}

{%- if annot.ocrText %}

{{annot.ocrText}}

{%- endif %}

{%- if annot.comment %}

  • {{annot.comment|nl2br}}

{%- endif -%}

{%- endfor -%}
{%- endfor -%}
{% endif %}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.