首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >苹果标签、苹果脚本和Evernote

苹果标签、苹果脚本和Evernote
EN

Stack Overflow用户
提问于 2017-12-23 14:23:06
回答 2查看 212关注 0票数 1

我使用下面的代码向Evernote添加文件,并在脚本添加这些文件时使用分配给这些文件的Apple标记转换为Evernote标记。

我使用的脚本很好,但有一个问题。我瞄准的文件有两个标签。

  • 测试标签
  • 测试

然后我运行脚本--这是Evernote中添加到导入文件中的内容。

添加到Evernote的标记

单个单词标签添加精细但和标签2字或更多放置引号周围的标签。我尝试过几种不同的方法来移除它们,但都没有用,所以我想我会在这里发帖,看看你们这些优秀的人是否有什么想法。

这是我用的密码。

代码语言:javascript
运行
复制
local targetNotebook, the_tags

set theFile to alias "Users:thomMacBook:Desktop:Inbox:outbox:test.pdf"


set the_tags to paragraphs of (do shell script "mdls -raw -name kMDItemUserTags " & quoted form of POSIX path of theFile & " | sed 's/^[()]$//g' | ruby -ne 'each = $_.strip.end_with?(\",\") ? $_.strip[0...-1] : $_.strip; puts each if each != \"\"'")

set targetNotebook to "Testing"

tell application "Finder"
set createdFileDate to (the creation date of (theFile as alias))
set modFileDate to (the modification date of (theFile as alias))
end tell
tell application "Evernote"
launch
set theItem to create note from file theFile notebook targetNotebook tags the_tags created createdFileDate
set (modification date of theItem) to modFileDate
end tell

提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-12-26 04:30:45

这对我起了作用:

代码语言:javascript
运行
复制
    set the_tags to paragraphs of (do shell script
        "mdls -raw -name kMDItemUserTags " & ¬
        quoted form of theFile & ¬
        " | egrep -o '\\w+(\\s*\\w+)+'")

通过对我的一个文件进行测试,它返回了以下列表:

代码语言:javascript
运行
复制
    {"Green", "Tag1", "This Tag", "Here Is Another Tag", "Tag2"}

我的regex表达式假设标记只由字母、数字和空格组成(我觉得这是一个合理的假设)。如果你有更多的异国情调标签,请留下评论,我会回复你的。

票数 1
EN

Stack Overflow用户

发布于 2017-12-24 04:21:22

下面是一个很好的例子,您可以跟随和/或从获取OS中的标签列表 on veritrope.com获得一些想法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47953260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档