Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Applescript以传输聚光灯注释和标签_Applescript_Finder_Spotlight - Fatal编程技术网

Applescript以传输聚光灯注释和标签

Applescript以传输聚光灯注释和标签,applescript,finder,spotlight,Applescript,Finder,Spotlight,我正在编写Applescript以获取文件夹列表,将其压缩到.zip文件,并将聚光灯注释和标签从文件夹传输到新文件 谢谢你给我的建议。这是最后的剧本 运行时{input,parameters} tell application "Finder" set theItems to selection repeat with i from 1 to (count of theItems) set theItem to (item i of theItems) as a

我正在编写Applescript以获取文件夹列表,将其压缩到.zip文件,并将聚光灯注释和标签从文件夹传输到新文件

谢谢你给我的建议。这是最后的剧本

运行时{input,parameters}

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

结束跑步

括号的魔力!和别名胁迫:

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