--2011-06-10
--http://organognosi.blogspot.com/
tell application "Skim"
set the clipboard to ""
set numberOfNote5 to (get text for note 5 of page 1 of document 1) as string
set pdfTitle to get (extended text of note 4) of page 1 of document 1 as string
set numberOfPages to count pages of document 1
activate
set myColorCodes to my chooseColor() --εκτός των loops πρέπει να βρίσκεται, μια φορά το θέτεις
display dialog "Do you want to export all the notes or only some of them?" buttons {"All", "Some"} default button 1
set answer to button returned of the result
if answer is "All" then
set firstPage to "1" as number
set lastPage to numberOfPages
set the clipboard to "===Skim notes===" & return
else
display dialog "Give me the written number of the first page." default answer ""
set firstPageWritten to text returned of the result as number
set firstPage to firstPageWritten - numberOfNote5 as number
display dialog "Give me the written numbers of the last page" default answer ""
set lastPageWritten to text returned of the result as number
set lastPage to lastPageWritten - numberOfNote5 as number
set the clipboard to (the clipboard) & "Notes from \"[[@" & pdfTitle & "]]\" (pages " & firstPage & " - " & lastPage & ")
" & return
end if
repeat with currentPage from firstPage to lastPage
--special provision for page 1
if currentPage is 1 then
set pageNotes to notes of page 1 of document 1
set notesAfter5 to items 6 thru -1 of pageNotes
exportPageNotes(notesAfter5, currentPage, myColorCodes) of me
else
set pageNotes to notes of page currentPage of document 1
exportPageNotes(pageNotes, currentPage, myColorCodes) of me
end if
end repeat
end tell
on exportPageNotes(listOfNotes, pageForProcessing, myColorCodes)
tell application "Skim"
set numberOfNote5 to (get text for note 5 of page 1 of document 1) as string
set pdfTitle to get (extended text of note 4) of page 1 of document 1 as string
set numberOfPageNotes to count notes of page pageForProcessing of document 1
set theWrittenPage to pageForProcessing + numberOfNote5 as string
set pdfDevonThinkLink to (get text for note 4 of page 1 of document 1) as string
set pdfDevonThinkLinkWihtoutZero to (text 1 thru ((length of pdfDevonThinkLink) - 1) of pdfDevonThinkLink) as string
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 pdfText to get text for coloredNote
set pdfText2 to get extended text of coloredNote as text
set fullNoteText to pdfText & " " & pdfText2
set annotationDate to modification date of coloredNote as text
set pageForDevonThinkLink to pageForProcessing - 1
--for use with MediaWiki semantic annotations
set firstCharacter to get the character 1 of fullNoteText
if firstCharacter = "[" then
set endofNote to "]]]"
else
set endofNote to "]"
end if
set textAfterFullNoteText to "[" & pdfDevonThinkLinkWihtoutZero & pageForDevonThinkLink & " p. " & theWrittenPage & endofNote & "
(" & annotationDate & ")
"
set textForTextMate to fullNoteText & " " & textAfterFullNoteText
set textForTextMate2 to replaceText(textForTextMate, "missing value", "") of me
set textForTextMate3 to replaceText(textForTextMate2, " ()", "") of me
set the clipboard to (the clipboard) & textForTextMate3 & return
end if
end repeat
end repeat
set theSeperationLine to ""
repeat with coloredNote in listOfNotes
if numberOfPageNotes > 0 then
repeat with i from 1 to the count of myColorCodes
if (color of coloredNote is item i of myColorCodes) then
set theSeperationLine to "----" & return
exit repeat
end if
end repeat
end if
end repeat
set the clipboard to (the clipboard) & theSeperationLine
end tell
end exportPageNotes
on replaceText(thisText, searchString, replacementString)
set AppleScript's text item delimiters to the searchString
set the itemList to every text item of thisText
set AppleScript's text item delimiters to the replacementString
set thisText to the itemList as string
set AppleScript's text item delimiters to {""}
return thisText
end replaceText
on chooseColor()
set selectedColors to (choose from list {"ice", "honey drew", "flora", "lemon", "cantaloupe", "silver"} with prompt ("Choose the color of notes for exporting (you can select multiple colors):") default items {"lemon"} with multiple selections allowed)
--selectedColors is a list of lists
set colorCodes to {}
set noteColor to ""
repeat with noteCol in selectedColors
set noteColor to noteCol as text
if noteColor is "ice" then
set end of colorCodes to {26214, 65535, 65535, 65535}
else if noteColor is "honey drew" then
set end of colorCodes to {52428, 65535, 26214, 65535}
else if noteColor is "flora" then
set end of colorCodes to {26214, 65535, 26214, 65535}
else if noteColor is "lemon" then
set end of colorCodes to {65535, 65535, 2, 65535}
else if noteColor is "cantaloupe" then
set end of colorCodes to {65535, 52428, 26214, 65535}
else if noteColor is "silver" then
set end of colorCodes to {52428, 52428, 52428, 65535}
end if
end repeat
return colorCodes
end chooseColor
Hey there,
Found your site today and your scripts seem to be very very useful for me
I’ve modded the simple on you provided here so that it won’t ask anything anymore. I’ve set the default highlighting color in Skim to “honeydew” and now the script just copies all my notes to the clipboard.
THought it might help someone else get some insight, as I’, just hacking and trying myself here. So I posted the code, if you don;t mind
Code:
– untitled.applescript
–
– Created by gerben jan on 2011-12-01.
– Copyright (c) 2011 __MyCompanyName__. All rights reserved.
–
–2011-06-10
–http://organognosi.blogspot.com/
tell application “Skim”
set the clipboard to “”
set numberOfPages to count pages of document 1
activate
–gehackt om de lemon vraag niet meer te krijgen
set myColorCodes to my chooseColor()
set firstPage to “1″ as number
set lastPage to numberOfPages
set the clipboard to “Skim notes” & 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 noteText to get text for coloredNote
set the clipboard to (the clipboard) & noteText & return & return
end if
end repeat
end repeat
end tell
end exportPageNotes
on chooseColor()
set colorCodes to {}
set noteColor to “”
set end of colorCodes to {52428, 65535, 26214, 65535}
return colorCodes
end chooseColor
–Color codes:
–”ice” {26214, 65535, 65535, 65535}
–”honey drew” {52428, 65535, 26214, 65535}
–”flora” {26214, 65535, 26214, 65535}
– “lemon” {65535, 65535, 2, 65535}
– “cantaloupe” {65535, 52428, 26214, 65535}
–”silver” {52428, 52428, 52428, 65535}
Thanks for your contribution!
Hi,
The script sounds great but I don’t understand the color definition. I can find the native RGBA from the color but not in the format you specified colors.
Could you give me a hint on how you defined these colors, even in Skim?
Thanks in advance
I hope my post http://www.organognosi.com/skim-and-highlighting-color-codes/ will help you.