Page 1 of 1

File name of extracted notes and annotations

Posted: Mon Sep 18, 2023 11:23 am
by atimm
Is there a way to set the citekey (ideally with a pre-configured prefix or suffix) as the file name for extracted notes and annotations? If this doesn't work out-of-the-box, could it be done through AppleScript? (Just to be clear, I have little to no experience with AppleScript but would struggle through if necessary.) Thanks in advance for any suggestions. This would simplify my workflow between Zotero, Bookends, and Obsidian.

Re: File name of extracted notes and annotations

Posted: Mon Sep 18, 2023 1:25 pm
by Jon
What is you workflow? Are you extracting one reference at a time, saving each as an individual markdown file? I think this could be done with AppleScript and UI scripting. DrJJWMac has been active in this regard. You might want to see these threads

viewtopic.php?t=5351&sid=20ece41ddf3ca4 ... b2e7e60699

https://forum.obsidian.md/t/workflow-ex ... dian/57867

I think the basic idea would be to have Bookends generate the markdown text, which the AppleScript would grab and save to disk with a file name you choose. If DrJJWMac doesn't see this thread, I don't think he'd mind if you ping him.

Jon
Sonny Software

Re: File name of extracted notes and annotations

Posted: Wed Sep 20, 2023 4:46 pm
by DrJJWMac
@atimm: I might presume as Jon mentions that you are saving one reference at a time. If so, what I see being possible is this ...

* Preconfigure the Extract Notes and PDF Annotations menu option with all the parameters that you want to have as the default using Selection as the option.
* Use AppleScript to ...
- grab and save the cite key from the current reference selection
- run the Extract Notes and PDF Annotations->Extract Now menu option
---> you get a dialog box to enter the file name ... this is anticipated with a pause in AppleScript
- enter the cite key as the file name (e.g. AppleScript does this)
* Allow you to manually hit the Save or Cancel (or New Folder) button

I might have a moment tomorrow to put an AppleScript together to do the above. If you have Keyboard Maestro installed, all the better, as the script could be directly linked to a button action.
KMButtonPanel.png
KMButtonPanel.png (115.52 KiB) Viewed 12943 times
The button action might be called -> Export As CiteKey.md. You would click it to get extract the current selection to the point of the (Cancel/Save) dialog box where the file name would already be preconfigured.

Re: File name of extracted notes and annotations

Posted: Thu Sep 21, 2023 9:32 am
by DrJJWMac
Here is a first draft.

Code: Select all

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

(*
Save CiteKey Markdown
v 2023-09-21
exports notes and PDF attachments from selected publication item
sets the export name to the cite key
*)

on run
	tell application "Bookends"
		activate
		set thePublications to selected publication items of front library window
		set theCiteKey to ((the user1 of item 1 of thePublications) & ".md") as text
		tell application "System Events"
			key code 14 using {command down}
			delay 2
			keystroke theCiteKey
		end tell
	end tell
end run