Here is an example for an AppleScript you can set for a Save Document script hook. It exports an RSS representation of the document in the same folder as the BibTeX file whenever the document is saved.
property theTemplateName : "Default RSS template" property theFileExtension : ".rss" using terms from application "BibDesk" on perform BibDesk action with publications thePubs for script hook theScriptHook -- get some properties from the script hook set theName to the name of theScriptHook set theDocument to the document of theScriptHook -- check if we get the right script hook event if theName is not "Save Document" then return -- get the document's file set theDocFile to the file of theDocument tell application "Finder" -- Finder redefines the file type, which is a mess set theDocFile to file theDocFile -- extract containing folder and file name set theFolder to the container of theDocFile set theFileName to the name of theDocFile -- change extension to "rss" set AppleScript's text item delimiters to "." if the name extension of theDocFile is not "" then set theFileName to text items 1 thru -2 of theFileName as text end if set theFileName to theFileName & theFileExtension set AppleScript's text item delimiters to "" -- create a reference to the file if necessary if file theFileName of theFolder exists then set theFile to (file theFileName of theFolder) as alias else set theFile to (make new file with properties {name:theFileName} at theFolder) as alias end if end tell -- now export using the template tell theDocument export using template theTemplateName to theFile end tell end perform BibDesk action with publications end using terms from |
The main thing that should be done in the script is to define a `perform BibDesk action with publications' subroutine to handle the script hook. An important thing to note is that you should bracket the whole subroutine in `using terms from application "BibDesk"', so that certain AppleScript definitions (such as the subroutine name) are recognized.
For another sample script, look in the Scripts Menu of BibDesk. To view its source, select the "Sample Script Hook" menu item with the Option key held down.