【问题标题】:Applescript to transfer spotlight comment and labelApplescript 转移聚光灯评论和标签
【发布时间】:2015-06-09 02:51:11
【问题描述】:

我正在编写 Applescript 来获取文件夹列表,将它们压缩为 .zip 文件,并将聚光灯注释和标签从文件夹转移到新文件。

感谢 CRGreen 的建议。这是最终的脚本。

在运行{输入,参数}

tell application "Finder"
    set theItems to selection
    repeat with i from 1 to (count of theItems)

        set theItem to (item i of theItems) as alias
        set itemPath to quoted form of POSIX path of theItem
        set theParent to POSIX path of (container of theItem as alias)
        set fileName to theParent & (name of theItem) & ".zip"

        set zipFile to quoted form of fileName
        do shell script "zip -jr " & zipFile & " " & itemPath
        do shell script "setfile -a E " & zipFile

        set newItem to POSIX file fileName as alias
        set comment of newItem to (get comment of theItem)
        set label index of newItem to (get label index of theItem)

        set oldFolder to quoted form of (theParent & name of theItem)
        do shell script "rm -rf " & oldFolder

    end repeat
end tell

return input

结束运行

【问题讨论】:

    标签: applescript finder spotlight


    【解决方案1】:

    括号的魔力! (和别名强制):

    set comment of ((POSIX file newItem) as alias) to theComment
    set label index of ((POSIX file newItem) as alias) to theLabel
    

    【讨论】:

      猜你喜欢
      • 2012-09-15
      • 1970-01-01
      • 1970-01-01
      • 2013-08-05
      • 2021-12-04
      • 1970-01-01
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多