使用 Applescript 导出基于标签的 URL 列表? [英] Using Applescript to export list of URLs based on tags?

查看:21
本文介绍了使用 Applescript 导出基于标签的 URL 列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Applescript 的新手,所以我在网上找到了一个很棒的脚本,它会列出所有具有关联 URL 的 Evernote 快照.为了列出所有带有 URL 的快照,这个解决方案很棒.如何修改此脚本以根据特定标签过滤列出的 URL?

I am new to Applescript, so I found an awesome script online that will list all Evernote snaps that have an associated URL . For listing all snaps with URLs, this solution is great. How could I modify this script to filter the listed URLs based on specific tags?

我目前使用的脚本: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

很抱歉我的代码块很时髦.如果有任何模组可以修复它,我将不胜感激.

Apologies for my code block being funky. If any mods can fix it I'd appreciate the help.

推荐答案

在您的 repeat with currentNote in allNotes 循环中,您可以添加如下内容:

In your repeat with currentNote in allNotes loop you could add something like this:

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

这篇关于使用 Applescript 导出基于标签的 URL 列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆