仅从evernote导出标签?

时间:2015-07-07 00:06:11

标签: applescript evernote

我发现了这个:Using Applescript to export list of URLs based on tags?,这是一个很好的资源。原始脚本(来自Veritrope)有点旧,但对于导出Evernote笔记标题非常有用。我认为修改这个脚本以使我的笔记本中的标签变成CSV是相对容易的。但是因为我非常喜欢编写脚本,并且自学成才,所以我无法使其工作。

有人能指出我正确的方向吗?我的最终目标是做一些标签维护,因为我现在有这么多标签,他们不再有用了。所以我只想要一个标签列表 - 不必与笔记相关联。一列数据。

谢谢,堆叠。

1 个答案:

答案 0 :(得分:1)

这是一个AppleScript程序,可以执行您想要的操作:

tell application "Evernote"
    set tagList to {}
    set allNotebooks to every notebook
    repeat with currentNotebook in allNotebooks
        set allNotes to every note in currentNotebook
        repeat with currentNote in allNotes
            set noteTags to (the tags of currentNote)
            repeat with currentTag in noteTags
                if tagList does not contain name of currentTag then
                    set the end of tagList to name of currentTag

                end if
            end repeat
        end repeat
    end repeat
end tell

set filePath to (path to desktop as text) & "Evernote Tags.csv"
set output to ""
repeat with currentTag in tagList
    set output to output & currentTag & ", "
end repeat

set theResult to writeTo(filePath, output, text, false)
if not theResult then display dialog "There was an error writing the data!"

on writeTo(targetFile, theData, dataType, apendData)
    -- targetFile is the path to the file you want to write
    -- theData is the data you want in the file.
    -- dataType is the data type of theData and it can be text, list, record etc.
    -- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
    try
        set targetFile to targetFile as text
        set openFile to open for access file targetFile with write permission
        if apendData is false then set eof of openFile to 0
        write theData to openFile starting at eof as dataType
        close access openFile
        return true
    on error
        try
            close access file targetFile
        end try
        return false
    end try
end writeTo