Skip to content

Instantly share code, notes, and snippets.

@Bollegala
Created October 26, 2019 23:07
Show Gist options
  • Save Bollegala/7cc6adafda38daa5638c98f5346c9cc1 to your computer and use it in GitHub Desktop.
Save Bollegala/7cc6adafda38daa5638c98f5346c9cc1 to your computer and use it in GitHub Desktop.
If you use BibDesk as your bibliography manager and you copy BibTex from acl anthology, then this script hook will (a) determine the PDF file from the bibtex entry and (b) download the PDF and link it to the bibdesk entry. You need to save this apple script and associate to "Import Publication" script hook in BibDesk. All credit goes to Christia…
property theURLPrefixes : {"https://www.aclweb.org/anthology/"}
property thePDFExtension : ".pdf"
on hasAnyPrefix(theString, thePrefixes)
repeat with thePrefix in thePrefixes
if theString starts with thePrefix then return true
end repeat
return false
end hasAnyPrefix
on fixURL(theURL)
if (my hasAnyPrefix(theURL, theURLPrefixes) and theURL does not end with thePDFExtension) then
if theURL ends with "/" then set theURL to text 1 thru -2 of theURL
set theURL to theURL & thePDFExtension
end if
return theURL
end fixURL
using terms from application "BibDesk"
on perform BibDesk action with publications thePubs for script hook theScriptHook
tell application "BibDesk"
repeat with thePub in thePubs
tell contents of thePub
set theURL to value of field "Url"
--display dialog theURL
set theFixedURL to my fixURL(theURL)
--display dialog theFixedURL
if (theURL is not theFixedURL) then
set value of field "Url" to theFixedURL
end if
if (count of linked URLs) > 0 then
set theURL to linked URL 1
set theFixedURL to my fixURL(theURL)
if (theURL is not theFixedURL) then
remove theFixedURL
add theFixedURL to beginning of linked URLs
--download linked URL 1 --with replace
download thePub
end if
end if
end tell
end repeat
end tell
end perform BibDesk action with publications
end using terms from
@mjpost
Copy link

mjpost commented Jan 2, 2023

Have you used this recently? I couldn't get it to work (I admittedly didn't try very hard), but if working, this could be useful for us to link from the Anthology.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment