1
如何使用AppleScript或Python列出我的Mac上可用的所有應用程序?
請幫助我。如何列出我的Mac上安裝的所有應用程序?
如何使用AppleScript或Python列出我的Mac上可用的所有應用程序?
請幫助我。如何列出我的Mac上安裝的所有應用程序?
檢查以下的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