I also attached the script as a file, since I noticed that my email client produced line breaks.
Claus
add-local-url.scpt
Description: application/applefile
add-local-url.scpt
Description: Binary data
-- Applescript for BibDesk -- add-local-url -- Claus Gerhardt, 2007(*Make sure that all items you are interested in are selected. The script will tell you in the "Result" how many items had been considered, and the value of the variables theAnswer and theFile of the last item. These variables may serve as a check, if the assumed file names (of the pdf files) are correct.*)
tell application "BibDesk" set theDoc to document 1--set theName to the name of window 1 -- usually the publication's title, if this is an editor window
tell theDoc set theSel to selection set l to 0 as number repeat with thePub in theSel try set theFirstname to first name of the author of thePub as string set theInitial to character 1 of theFirstname set theLastname to the last name of the author of thePub as string set theName to theLastname & theInitial set theYear to value of field "Year" of thePub as string --set theTitle to value of field "Title" of thePub as string set theTitle to title of thePub set l to l + 1 as number set n to (number of characters of contents of theTitle) set i to 1 as number repeat while i < (n + 1) if character i of theTitle is equal to "{" then set k to iset theTitle to (characters 1 thru (k - 1) of theTitle as string) & (characters (k + 1) thru n of theTitle as string)
--set foundText to theAuthor as string set n to (number of characters of contents of theTitle) set i to (i + 1) else set i to (i + 1) end if end repeat set n to (number of characters of contents of theTitle) set i to 1 as number repeat while i < (n + 1) if character i of theTitle is equal to "}" then set k to iset theTitle to (characters 1 thru (k - 1) of theTitle as string) & (characters (k + 1) thru n of theTitle as string)
--set foundText to theAuthor as string set n to (number of characters of contents of theTitle) set i to (i + 1) else set i to (i + 1) end if end repeatset dirName to (do shell script "dirname " & "~/Documents/ Articles/" & theName & "/ex") --set dirName to (do shell script "dirname " & "~/Documents/ Downloads/ex") set theFile to POSIX file (dirName & "/" & theYear & "-" & theTitle & ".pdf")
try tell application "Finder" get file theFile set theAnswer to "Yes" end tell on error set theAnswer to "No" end try if theAnswer is equal to "Yes" thenset value of field "Local-Url" of thePub to "file://localhost" & dirName & "/" & theYear & "-" & theTitle & ".pdf"
end if end try end repeat end tell end tell {l, theAnswer, theFile}
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ Bibdesk-users mailing list Bibdesk-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-users