2013-02-04 29 views
0

我是Applescript的新手,所以我在網上發現了一個很棒的腳本,它將列出所有擁有關聯URL的Evernote捕捉。爲了列出所有包含URL的捕捉,這個解決方案非常棒。我如何修改這個腳本來根據特定標籤過濾列出的URL?使用Applescript根據標籤導出URL列表?

腳本我目前正在使用:http://veritrope.com/code/save-a-list-of-urls-from-your-evernote-items-as-a-file/

tell application "Evernote" 
    activate 
    set listOfNotebooks to {} 


    set EVNotebooks to every notebook 
    repeat with currentNotebook in EVNotebooks 
     set currentNotebookName to (the name of currentNotebook) 
     copy currentNotebookName to the end of listOfNotebooks 
    end repeat 

    set Folders_sorted to my simple_sort(listOfNotebooks) 


    set SelNotebook to choose from list of Folders_sorted with title "Select Evernote Notebook" with prompt ¬ 
     "Current Evernote Notebooks" OK button name "OK" 
    set EVnotebook to item 1 of SelNotebook 
    set listofNotes to {} 
    set note_Records to {} 
    set allNotes to every note in notebook EVnotebook 
    repeat with currentNote in allNotes 
     try 
      set currentNoteURL to (the source URL of currentNote) 
      set currentNoteTitle to title of currentNote 
      if currentNoteURL is not missing value then 
       copy currentNoteURL to the end of listofNotes 
       copy {name:currentNoteTitle, URL:currentNoteURL} to the end of note_Records 
      end if 
     end try 
    end repeat 


    set Notes_sorted to my simple_sort(listofNotes) 
    set SelNote to ¬ 
     choose from list of Notes_sorted with title ¬ 
      "List Of URLs In Notes" OK button name "Export List" cancel button name "Close Window" with empty selection allowed 


    set record_Text to {} 
    repeat with note_Record in note_Records 
     set theCurrentRecord to ("Title: " & name of note_Record & return & "URL: " & URL of note_Record & return & return) as text 
     copy theCurrentRecord to the end of record_Text 
    end repeat 


    if (SelNote is not false) then 
     tell application "System Events" 
      -- convert list to text FILE 
      set ExportList to "Current List of URLs in Notes for " & EVnotebook & "-- " & (current date) & return & return & record_Text as Unicode text 
      set fn to choose file name with prompt "Name this file" default name "URL List for Notebook Named " & EVnotebook & ¬ 
       ".txt" default location (path to desktop folder) 
      set fid to open for access fn with write permission 
      write ExportList to fid 
      close access fid 
     end tell 
    else 
     set EVnotebook to item 1 of SelNotebook 
    end if 
end tell 

on simple_sort(my_list) 
    set the index_list to {} 
    set the sorted_list to {} 
    repeat (the number of items in my_list) times 
     set the low_item to "" 
     repeat with i from 1 to (number of items in my_list) 
      if i is not in the index_list then 
       set this_item to item i of my_list as text 
       if the low_item is "" then 
        set the low_item to this_item 
        set the low_item_index to i 
       else if this_item comes before the low_item then 
        set the low_item to this_item 
        set the low_item_index to i 
       end if 
      end if 
     end repeat 
     set the end of sorted_list to the low_item 
     set the end of the index_list to the low_item_index 
    end repeat 
    return the sorted_list 
end simple_sort 

道歉我的代碼塊是時髦的。如果任何MODS可以解決它,我會很感激幫助。

+0

我固定的格式問題。注意:插入代碼的簡單方法是:粘貼,選擇它並點擊{}按鈕。對於你的問題:究竟什麼是「特定標籤」,屬於什麼? – 2013-02-04 23:31:45

+0

感謝您的格式化幫助! 我會嘗試獲取有關標籤的更多信息。我對Applescript和Evernote都是全新的,但我需要在我的工作中做到這一點。我會看看是否可以獲取關於標籤及其與快照關聯的明確信息。 – user1729506

+0

不再需要:)(請參閱Michele的回答) – 2013-02-05 18:58:44

回答

0

在你repeat with currentNote in allNotes循環中,您可以添加這樣的事情:

set allTags to tags of currentNote 
repeat with currentTag in allTags   
    if name of currentTag is "your_specific_tag" then 
     do what you want 
     ........... 
    end if 
end repeat 
+0

我在這裏假設您對evernote的標籤感興趣,但也許情況並非如此...... –

+0

是的,Evernote中的標籤。其他人正在使用印象筆記,並希望腳本來完成這項任務。 _many_快照中有無數個標籤。我想他們可能想要輸入標籤進行過濾。非常感謝該片段。我會給它一個去,讓你知道它是如何工作的! – user1729506

+0

將 '設置allTags到currentNote 重複與currentTag的標籤allTags 如果currentTag的名稱是「your_specific_tag」然後 嘗試 集currentNoteURL到(currentNote源URL) 集currentNoteTitle到如果currentNote 的標題currentNoteURL都不缺值,那麼 副本currentNoteURL到listofNotes 拷貝結束{名稱:currentNoteTitle,網址:currentNoteURL}到note_Records結束 結束時,如果 結束嘗試 結束時,如果 結束repeat' 要安全下注嗎? – user1729506

相關問題