如何使用AppleScript或Python列出我的Mac上可用的所有应用程序? 请帮帮我。
答案 0 :(得分: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"
[....]
}
上面的脚本基于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