Hi all,
I’ve searched for this, but haven’t found anything I can use…
I use Zotero solely as a citations and bibliography manager. All files (pdf, snapshots, webarchives etc.) are stored in DT. What I’d like to do, is to get an rtf-Note in DT for every entry in Zotero.
I have (very) basic knowledge of AppleScript, but haven’t been able to work this out (one idea was make a DT-record for every Row in a BibTex sheet linked with Zotero…)
Pointers? Any help appreciated!
Perhaps?
Give this a try - @retorquere got this working for me recently and I find it to be quite useful
Thanks for the pointers!
Changing the Bibdesk script to work with zotero (i.e. bibtext export files) is a bit out of my depth, and I don’t really want to use Bibdesk as an “intermediary application”.
I haven’t managed to get the @retorque package to run (yet).
What I was hoping for was something similar to the “Import References from Bookends” commodity
Cheers
As it turned out, directly accessing the sqlite database isn’t practical, since the format can change with each new Version of Zotero
(–> https://www.zotero.org/support/dev/client_coding/direct_sqlite_database_access: “Also be aware that the SQLite database structure can change between Zotero releases.”)
So I’ve figured out a script that’ll open a BibTex sheet (or any other for that matter), create a RTF-record with Title, Author and Year for every entry (row), and then close the sheet.
So for what it’s worth, here’s the script. Please feel free to use and/or modify it as you choose.
Sheet to RTF.pdf (51.5 KB)
So here’s the latest version. Thanks bluefrog for pointing out how to render script as code blocks.
-- When run from within a group or with a highlighted group in Devonthink this script will grab the entries from a sheet and create a rtf-file for every entry (row). I use it with Zotero, and export my Zotero Library with BetterBiblaTex ( Other formats may have different field-positions) with "keep updated" checked as an export option. I have a group named "Zotero" in which I keep an indexed verserion of the BibTex file named "Zotero".
-- Whereas this script is written for use with Zotero and BiblaTex sheets, it can easily be adapted to extract data from other sheets in DevonThink
--Use at your own risk!
-- Ed Guerin 2019
tell application id "DNtp"
open window for record child 1 of current group
activate
--this opens the sheet (unfortunately I haven't found a means to perform operations on a closed or hidden sheet)
tell think window 1
set shorti to ""
set singl to ""
set nRow to ""
set reihe to 1
set zz to 4
set yy to 1
set tit to ""
set aut to ""
set imp to ""
set jhr to ""
set fini to 1
set destGroup to "/Zotero/"
set currRow to 1
set rws to number of rows
set cls to number of columns
set rws to rws
if rws < 0 then
display alert "No sheet available"
return
end if
repeat with yy from 1 to rws
show progress indicator "Processing " & rws & " entries ..." steps 2
--################################################
-- zz should be set to the columns (i.e. fields) to be read. In my case only fields 3, 6 and 7 are relevant
--################################################
repeat with zz from 3 to 7
set singl to get cell at row yy column zz
-- as text
if zz = 3 then set tit to singl
if zz = 6 then set jhr to singl
if zz = 7 then set aut to singl
set singl to ""
end repeat
set nRow to yy as text
--######################################
-- remove all instances of "/", "|" and " "
--###############################################
set chk to offset of "/" in tit
if chk > 0 then
set tit1 to replText(tit, "/", " - ") of me
set tit to tit1
set chk to 0
end if
set chk to offset of "|" in tit
if chk > 0 then
set tit1 to replText(tit, "|", " - ") of me
set tit to tit1
set chk to 0
end if
set chk to offset of " " in tit
if chk > 0 then
set tit1 to replText(tit, " ", "") of me
set tit to tit1
set chk to 0
end if
--##################################
set nRow to tit & " (" & nRow & ")"
--set nRow to nRow & ". " & tit
if jhr = "" then set jhr to "(o.J.)"
set lfd to "
"
set titx to tit
set imp to aut & lfd & titx & lfd & jhr & lfd
set theLocation to create location destGroup
set finrec to destGroup & nRow
if not (exists record at finrec) then
set newRecord to create record with {name:nRow, type:rtf, rich text:imp} in theLocation
tell text of newRecord
set (font of every attribute run of paragraph 2) to "Arial Rounded MT Bold"
set (size of every attribute run of paragraph 2) to 11
end tell
set fini to fini + 1
end if
set zz to 4
set nRow to ""
set imp to ""
set aut to ""
set jhr to ""
set tit to ""
set aut to ""
end repeat
set fini to fini - 1 as string
set fini to fini & " titles were added"
hide progress indicator
close
display dialog fini
end tell
end tell
-- ##############################################
-- subroutine to search and replace
--###############################################
on replText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end replText
My pleasure