列出所有应用程序 - 输出为文本文件 [英] List all applications - output as text file

查看:23
本文介绍了列出所有应用程序 - 输出为文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何找到安装在 Mac OS X 10.5 上的所有应用程序,最好使用 applescript,并将所有应用程序名称输出到文本文件中.

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.

推荐答案

Mac OS X 下安装的所有应用程序都注册在 启动服务数据库.

All the applications installed under Mac OS X are registered in the Launch Services database.

Launch Services 框架包含一个辅助 shell 命令 lsregister,它可以转储 Launch Services 数据库中存储的信息.在 Mac OS X 10.5 和 10.6 下,该命令位于以下文件夹中:

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

使用几个简单的 grep 过滤器就可以提取所有已注册应用程序的完整路径:

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"

综合起来,以下 AppleScript 将使用 信息命令:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆