2015-04-04 135 views
0

我正在編寫Applescript以獲取文件夾列表,將它們壓縮爲.zip文件,並將聚光燈註釋和標籤從文件夾轉移到新文件。AppleScript轉移焦點評論和標籤

感謝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 

運行結束

回答

0

括號的魔力! (和別名強制):

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