2014-05-24 12 views
1

일부 배경 : 과학 저널 기사를 읽고 주석을 달기 위해 BibDesk에서 Skim을 사용했습니다. 최근에 안드로이드 타블렛을 구입하여 .pdfs를 읽고 주석을 달기 위해 사용하고 싶습니다. 참조 라이브러리 EratosthenesezPDF Reader과 함께 사용하고 Dropbox를 통해 모든 파일을 동기화합니다. 내가 가지고있는 문제는 Skim이 기본적으로 주석을 확장 속성 파일로 저장한다는 점입니다. Dropbox를 통해 다른 장치에 액세스 할 수 없습니다. 주석을 .fdf 파일로 저장 한 다음 .fdf 파일을 BibDesk의 인용 항목에 연결하여이 문제를 해결했습니다. ezPDF 리더는 .fdf 파일을 주석으로 가져올 수 있으며, 주석 파일이 BibDesk 항목에 링크되어 있으면 .pdf와 .fdf는 수 백개의 참조로 가득 찬 전체 Dropbox 폴더를 동기화하지 않고도 쉽게 태블릿에 다운로드 할 수 있습니다.Skim 주석을 인용문 입력에 연결하는 BibDesk 스크립트

저는이 작업을 자동으로 수행하는 applescript를 작성하고 싶습니다. 그러나 매우 새로운 applescript이며 시작하는 데 어려움을 겪고 있습니다. 동시에 .FDF 파일을 내보내는 동안

tell application "Skim" 
    set docPath to path of front document 
    set notesPath to text 1 thru -5 of docPath & ".fdf" 
    save front document 
    save front document in notesPath as "Notes as FDF" 
end tell 

이 본질적으로 현재 문서를 저장합니다 나는 탈지에있는 동안 "명령의"를 눌렀을 때 실행되는 다음 스크립트를 작성했습니다. 동일한 스크립트 내에서 .fdf 파일을 BibDesk의 적절한 인용 항목에 연결하고 싶습니다. 이것은 포함합니다 :

  • 가 .FDF 파일이 이미 연결되어 있는지 확인하기 위해
  • 검사 (아마도 전면 문서에 링크를 찾을 항목을 검색)을 .PDF와 관련된 인용 항목 이름을 결정
  • 없는 경우, .FDF 내가 첫 번째 단계를지나 얻을 수없는 정말 비슷한 일을하고 있어요 사람을 찾을 수 없어

파일을 첨부합니다.

tell application "BibDesk" 
    set thePub to selection 
    tell thePub 
     set theFieldName to "Local-URL-2" 
    set value of field theFieldName to fdfPath 
    end tell 
end tell 

이 코드의 두 번째 부분으로 나를 도울 수 AppleScripts를 Bibdesk을 잘 알고 누구인가 : 나는 어떤 결과를 얻을 수없는 기본 일 (.FDF 파일이 링크되지 않은 가정, 인용 항목이 강조 가정)을 작성 시도 ?

대단히 감사합니다.

답변

1

다음 코드는 나의 초기 질문에 만족스럽게 대답합니다. 첫 번째 절에서는 저장 및 내보내기 명령을 반복합니다. 두 번째 섹션은 링크 된 .pdf 파일 (Skim의 앞면 문서)이 포함 된 인용문 항목을 찾습니다. 세 번째 섹션에서는 .fdf 파일을 인용문 항목에 첨부합니다 (도움이 필요하면 CRGreen 덕분입니다).

--save and export .fdf file 
tell application "Skim" 
    set docPath to path of front document 
    set fdfPath to text 1 thru -5 of docPath & ".fdf" 
    save front document 
    save front document in fdfPath as "Notes as FDF" 
end tell 

--search for relevant citation entry 
tell document 1 of application "BibDesk" 
    --sort all publications in library by Cite Key 
    set thePubs to (sort (get publications) by "Cite Key") 
    -check each publication individually (surely this is not the most efficient way to do this) 
    repeat with aPub in thePubs 
     --check to see if the .pdf is in the citation entry 
     tell aPub 
      if linked files contains (POSIX file docPath) then 
       set thePub to aPub 
       --once the citation is found, exit loop 
       exit repeat 
      end if 
     end tell 
    end repeat 

    --link the .fdf file to the citation entry (if it isn't already) 
    tell thePub 
     --if the fdf file exists in the linked file, do nothing 
     if linked files does not contain (POSIX file fdfPath) then 
      add (POSIX file fdfPath) to end of linked files 
     end if 
    end tell 
end tell 

나는 관련 .pdf 파일로 인용 항목을 검색 할 수있는 더 좋은 방법이 있으리라 믿고있어 (아마 AppleScript로 검색 명령을 사용하여이?). 이 솔루션은 저에게 도움이됩니다. 그러나이 문제를 해결하는 좀 더 우아한 방법을 알고 있다면 자유롭게 언급하십시오.

스크립트를 키보드 단축키 ("command-s"가 편리함)에 매핑하려면 here (메뉴 제목은 스크립트 이름 임)을 참조하십시오. 먼저 스크립트를 ~/Library/Application Support/Skim/Scripts 디렉토리에 저장해야합니다.

저는 방금 applescript를 배우는 중이며, 이것이 대부분의 경우 매우 간단한 운동 이었지만 다른 초보자에게 도움이 될 것임을 알고 있습니다.

1

나는 BibDesk 스크립팅에 너무 익숙하지 않지만 조금 훑어보고 있습니다. 귀하를 안내 할 수 있도록 크게 도움을주었습니다 :

set theFieldName to "Local-URL-2"--generally better not to put 
--something like this in a tell block if it isn't necessary 

tell application "BibDesk" 
    --as you have it, you are simply putting the selection class 
    --into a variable. here we reference the specific selection 
    --object of the document object: 
    set thePubSel to selection of document 1 
    --and, since this returns a *list* of pubs, I'm grabbing just the first item 
    --(but a loop iterating through every publication in the selection perhaps better) 
    set thePub to item 1 of thePubSel 

    tell thePub 
     set value of field theFieldName of it to fdfPath 
    end tell 
end tell 
+0

BibDesk은 AppleScript 로의 통합에서 (Skim이) 꽤 좋은 것처럼 보입니다. BibDesk 웹 사이트에서 사용할 수있는 스크립트 예제를 살펴 보는 것이 좋습니다. – CRGreen

+0

도움을 주셔서 대단히 감사합니다. 특히 코드에 대한 많은 논평을 부탁드립니다. 당신이 제공 한 코드는 내가 작성한 것을 개선 한 것이지만 불행히도 원래 코드에는 뭔가 잘못되었습니다. "Local-URL-2"필드에 파일 이름을 저장해도 파일이 항목에 연결되지 않습니다. 내 대답은 아래에 표시된대로 문제 의이 부분을 해결했습니다. 그러나, 나는 여전히 .pdf 파일에 해당하는 인용문 항목을 식별하는 방법을 찾지 못했습니다. – apogalacticon