2012-09-04 60 views

回答

1

檢查以下的AppleScript:

set theResult to every paragraph of (do shell script "mdfind 'kMDItemContentTypeTree == \"com.apple.application\"c' | sort") 
set systemApps to {} 
set applicationsApps to {} 

repeat with i from 1 to number of items in theResult 
    set end of systemApps to item i of theResult 
    if item i of theResult contains "/Applications/" then 
     set end of applicationsApps to item i of theResult 
    end if 
end repeat 

systemApps列表包含系統上的應用程序,例如:

{ 
"/Applications/Address Book.app", 
"/Applications/Calculator.app", 
"/Library/Image Capture/Devices/EPSON Scanner.app", 
"/Library/Little Snitch/Little Snitch Network Monitor.app", 
"/Library/Scripts/ColorSync/Show Info.app", 
[....] 
} 

applicationsApps列表包含應用程序文件夾的應用程序,例如:

{ 
"/Applications/Address Book.app", 
"/Applications/App Store.app", 
"/Applications/Automator.app", 
"/Applications/Calculator.app", 
"/Applications/Utilities/Activity Monitor.app" 
[....] 
} 

scr上面的ipt是基於Ross的腳本(見Mac OSX Hints Forums):

set appString to do shell script "mdfind 'kMDItemContentTypeTree == \"com.apple.application\"c' | sort" 
set appList to every paragraph of appString 
set theReport to "" 
repeat with i from 1 to number of items in appList 
set theItem to item i of appList 
set theApp to (a reference to POSIX file theItem) 
set fileInfo to info for theApp 
set versionInfo to long version of fileInfo 
if versionInfo is missing value then set versionInfo to " " 
set theReport to theReport & theItem & " " & versionInfo & return 
end repeat 
theReport 
相關問題