Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to get a list of every application on my computer?

I'm trying to figure out how to get a list of every application on my computer using applescript. I know it is possible for the system to do this, as evidenced by the dialog you get when you use the "choose application" function. Other examples are doing a spotlight search for "kind:app" or programs like Namely or QuickSilver.

Is there a way to do this in applescript? The only solution I've come up with so far is to use the command:

<pre>set every applicationaliases to choose application as alias with multiple selections allowed</pre>

and manually select all on the resulting dialog. I can then take the results and go from there, however there are a few significant problems with this approach.

1. It requires user interaction. (I have an idea for some future applications that could use this functionality if it can be done without user input.)
2. It's horribly slow. As a test run I choose all the applications from the dialog, extracted some basic info and put the result on the clipboard. It took a couple of minutes to complete this relatively basic task. In comparison, running the aforementioned spotlight search took maybe ten seconds.

Thanks in advance!

best,
peter

Powermac G4 Dual 867 / 1GB / 330GB / ComboDrive (broken), Mac OS X (10.4.10), 17" Studio Display / 20GB iPod (2nd gen) / Pismo running server duty

Posted on Oct 11, 2007 12:12 PM

Reply
Question marked as Best reply

Posted on Oct 11, 2007 12:41 PM

Will this work for you?

<pre>set appList to paragraphs of (do shell script "mdfind \"kMDItemKind == Application\"")</pre>

Message was edited by: James Nierodzik
9 replies

Oct 11, 2007 1:08 PM in response to James Nierodzik

That works quite well, thanks!

One odd thing, though, is that running that command gives me 1,684 results, whereas the spotlight search for "kind:app" (or "kind:application", which is of course as equivalent) gives me 2,839 results. I looked through the results of mdfind to see if it was excluding one of my drives, but it isn't. Any ideas why this might be?

Oct 11, 2007 1:31 PM in response to peter weber

Ha, turns out there was a difference on my system as well. I think the issue happens to be, at least in my case it was, with widgets. If you do a md look up on a widget

<pre>set x to do shell script "mdls '/Library/Widgets/Calculator.wdgt'"</pre>

You get back "Widget" as the type for the ItemKind atrribute and thus they do not show up in mdfind. I think Spotlight is assuming you want to look for these as well when you search for applications so its doing a complex search.

To further back this up when I do a spotlight search for kind:application I get back 331 results. When I do a mdfind for app I get 293. When I do a mdfind for widget I get 38.

38 + 293 = 331 =)

Oct 11, 2007 2:18 PM in response to James Nierodzik

Very interesting. When I do mdfind for widget I get 318 and when I do mdfind for application I get 1684, totaling 2002, which still leaves 837 spotlight results unaccounted for... I'm more prepared to believe that I have 1684 "applications" than 2839, but I still wonder why the huge difference...

I ruled out network shares, since I don't have any mounted and added up the subtotals that spotlight gives for each of my drives/partitions. I also checked to see if applescripts (.scpt files) were being included, but mdfind gave me 1541 results for the kind "script", which is obviously way too many.

Too bad I don't have Leopard, the more sophisticated search capabilities of spotlight would really help! 🙂

Edit: I did find that spotlight is finding Classic Applications as well as normal apps, which may account for the difference. I can't, however, figure out how to verify this using mdfind. For example, mdls shows me that the kMDItemKind for the Chooser is "Classic Application", but my attempts to use mdfind to locate items with that kind don't work...

Message was edited by: peter weber

Oct 11, 2007 2:24 PM in response to peter weber

The interesting there here too is that when I so a Command+F and do a search across the computer for Kind:Application I get the same amount of results as I do with mdfind NOT the same amount I get by actually using spotlight.

If you could eyeball an entry it's finding in spotlight, but not the other methods and list its metadata attributes I would love to see the results.

Oct 11, 2007 2:59 PM in response to peter weber

You need to either escape your search term with quotes or wild card it, so to find anyitem with Application in its ItemKind, classic or otherwise, do..

<pre>set appList to paragraphs of (do shell script "mdfind \"kMDItemKind == Application\"")</pre>

Getting a wildcarded or search though to work with application and widget however is being more problematic

Oct 11, 2007 3:49 PM in response to James Nierodzik

Actually give this one a try, it will search for Applications, classic or otherwise, and widgets...

<pre>set appList to paragraphs of (do shell script "mdfind \"(kMDItemKind = ' application'c) || (kMDItemKind = ' widget'c)\"")</pre>

Also, using a play from Apple's book, I would be curious to see if the above count differs from this one

<pre>set appList to paragraphs of (do shell script "mdfind \"(kMDItemKind = ' Application'c) || (kMDItemKind = ' Widget'c) || ((kMDItemContentTypeTree = 'com.apple.application') && (kMDItemContentType != com.apple.mail.emlx) && (kMDItemContentType != public.vcard))\"")</pre>

Look forward to your results.

Oct 12, 2007 11:34 AM in response to James Nierodzik

For these specific queries my results are...

set appList to paragraphs of (do shell script "mdfind \"(kMDItemKind = ' application'c) || (kMDItemKind = ' widget'c)\"")
3082

set appList to paragraphs of (do shell script "mdfind \"(kMDItemKind = ' Application'c) || (kMDItemKind = ' Widget'c) ||
((kMDItemContentTypeTree = 'com.apple.application') && (kMDItemContentType != com.apple.mail.emlx) && (kMDItemContentType != public.vcard))\"")
3115

I think I finally found some numbers that make sense!

When I search for Kind:Application by the Command+F method in the Finder, I get a total of 2521 items, of which 2477 are "Applications" and 44 are "Other".
(Just by eyeballing it, "Other" seems to include some Classic Apps and some .bundle files.)

The total # found by this method (2521) plus the number of Widgets found using mdfind (318) equals the number of total number of items found by spotlight (2839).

I also noticed that these numbers almost equal the spotlight number:

mdfind results for kMDItemKind:
Widgets: 318
Applications: 1684
Classic*: 795
and
Command+F "Other" items: 44

318 1684+79544 = 2841

It may be a fluke that this is so close to the 2839 spotlight gives, or maybe there's an overlap somewhere...

Tying this back into my initial question, it seems like the original mdfind command for Applications is probably the best answer for what I was looking for,
since I wasn't really thinking about Classic apps and Widgets anyway.

How to get a list of every application on my computer?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.