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