列出所有的应用程序 - 输出为文本文件 [英] List all applications - output as text file
问题描述
我只是想知道有人会如何去使用preferably的AppleScript和输出他们所有的应用程序名称到一个文本文件中查找已安装在Mac OS X 10.5的所有应用程序。
在Mac OS X上安装了所有应用程序都注册在<一个href=\"http://developer.apple.com/mac/library/documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html\"相对=nofollow>启动服务数据库。
该发射服务框架包含了一个帮手shell命令 lsregister
对其他用途可以转储存储在发射服务数据库的信息中。在Mac OS X 10.5和10.6的命令位于以下文件夹:
使用几个简单的grep过滤器可以提取所有注册的应用程序的完整路径:
lsregister -dump | grep的--AFTER上下文1捆绑^| grep的--only匹配/.*\\.app
全部放在一起,下面的AppleScript将通过计算所有注册的应用程序的用户可见名称<一个href=\"http://developer.apple.com/mac/library/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW14\"相对=nofollow>为命令信息:
属性pLSRegisterPath: \"/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister\"设置theAppPaths到每一个段落(做shell脚本pLSRegisterPath&安培;-dump | grep的--AFTER上下文1 \\^捆绑\\| grep的--only匹配\\/.* \\\\应用程序\\)集theNames到{}
与thePath重复theAppPaths
尝试
的(对于(thePath为POSIX文件)INFO)结束theNames的副本显示的名称
年底试
重复结束
从列表中选择theNames
I was just wondering how someone would go about finding all the applications that are installed on Mac OS X 10.5 using preferably applescript and output all their application names to a text file.
All the applications installed under Mac OS X are registered in the Launch Services database.
The Launch Services framework contains a helper shell command lsregister
which among other uses can dump the information stored in the Launch Services database. Under Mac OS X 10.5 and 10.6 that command is located in the following folder:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister
Using a few simple grep filters one can extract the full paths of all registered applications:
lsregister -dump | grep --after-context 1 "^bundle" | grep --only-matching "/.*\.app"
Putting it all together, the following AppleScript will compute the user visible names of all registered applications using the info for command:
property pLSRegisterPath : "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
set theAppPaths to every paragraph of (do shell script pLSRegisterPath & " -dump | grep --after-context 1 \"^bundle\" | grep --only-matching \"/.*\\.app\"")
set theNames to {}
repeat with thePath in theAppPaths
try
copy displayed name of (info for (thePath as POSIX file)) to end of theNames
end try
end repeat
choose from list theNames
这篇关于列出所有的应用程序 - 输出为文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!