public
Last active

Grabbing notes from PDFs

  • Download Gist
gistfile1.applescript
AppleScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
(*
 
Script courtesy of Walton Jones, modified slightly
http://drosophiliac.com/2012/09/an-academic-notetaking-workflow.html
 
Original script by John Sidiropoulos
http://www.organognosi.com/export-skim-notes-according-to-their-highlight-colors/
 
*)
 
tell application "Skim"
set the clipboard to ""
set numberOfPages to count pages of document 1
activate
set myColorCodes to my chooseColor()
set firstPage to "1" as number
set lastPage to numberOfPages
set the clipboard to "# Notes #" & return & return
repeat with currentPage from firstPage to lastPage
set pageNotes to notes of page currentPage of document 1
exportPageNotes(pageNotes, currentPage, myColorCodes) of me
end repeat
end tell
 
on exportPageNotes(listOfNotes, pageForProcessing, myColorCodes)
tell application "Skim"
set currentPDFpage to pageForProcessing
repeat with coloredNote in listOfNotes
repeat with i from 1 to the count of myColorCodes
if color of coloredNote is item i of myColorCodes then
set categoryColors to ({"Summary", "Methods", "Arguments", "Reference", "Thesis", "Question or connection"})
set noteColor to color of coloredNote as string
if noteColor is item i of myColorCodes as string then
set noteColor to item i of categoryColors
end if
set noteText to get text for coloredNote
set the clipboard to (the clipboard) & "**[" & noteColor & "]" & "(file://" & name of document 1 & "#page=" & pageForProcessing & ")**" & ": " & return & noteText & return & return
end if
end repeat
end repeat
end tell
end exportPageNotes
 
on chooseColor()
set selectedColors to ({"Summary", "Methods", "Arguments", "Reference", "Thesis", "Question or connection"})
set colorCodes to {}
set noteColor to ""
repeat with noteCol in selectedColors
set noteColor to noteCol as text
if noteColor is "Summary" then
set end of colorCodes to {64634, 900, 1905, 65535}
else if noteColor is "Methods" then
set end of colorCodes to {64907, 32785, 2154, 65535}
else if noteColor is "Arguments" then
set end of colorCodes to {65535, 65531, 2689, 65535}
else if noteColor is "Reference" then
set end of colorCodes to {8608, 65514, 1753, 65535}
else if noteColor is "Thesis" then
set end of colorCodes to {8372, 65519, 65472, 65535}
else if noteColor is "Question or connection" then
set end of colorCodes to {64587, 1044, 65481, 65535}
end if
end repeat
return colorCodes
end chooseColor

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.