我使用下面的代码向Evernote添加文件,并在脚本添加这些文件时使用分配给这些文件的Apple标记转换为Evernote标记。
我使用的脚本很好,但有一个问题。我瞄准的文件有两个标签。
然后我运行脚本--这是Evernote中添加到导入文件中的内容。
单个单词标签添加精细但和标签2字或更多放置引号周围的标签。我尝试过几种不同的方法来移除它们,但都没有用,所以我想我会在这里发帖,看看你们这些优秀的人是否有什么想法。
这是我用的密码。
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
提前感谢
发布于 2017-12-26 04:30:45
这对我起了作用:
set the_tags to paragraphs of (do shell script
"mdls -raw -name kMDItemUserTags " & ¬
quoted form of theFile & ¬
" | egrep -o '\\w+(\\s*\\w+)+'")
通过对我的一个文件进行测试,它返回了以下列表:
{"Green", "Tag1", "This Tag", "Here Is Another Tag", "Tag2"}
我的regex表达式假设标记只由字母、数字和空格组成(我觉得这是一个合理的假设)。如果你有更多的异国情调标签,请留下评论,我会回复你的。
发布于 2017-12-24 04:21:22
下面是一个很好的例子,您可以跟随和/或从获取OS中的标签列表 on veritrope.com获得一些想法。
https://stackoverflow.com/questions/47953260
复制相似问题