2

Automator treats .app files (Application Packages) as if they were folders. This might be useful in some instances, but for what I want to do - Periodically make a list of the contents of my Applications folder - it is extremely frustrating.

I just want a list of all the applications I have. I made a two step workflow, with "Get Folder Contents" and "New Text File". This would work perfectly, if not for the fact that I have a number of subfolders in the Applications folder with apps in there (for organization/sanity purposes).

In theory, this would be solved by checking the "Repeat for each subfolder found" option in the "Get Folder Contents" Action, but this gives me a huge problem: it lists every single file in each App Package, which I'm sure you'll understand is totally useless for my purposes.

Any Ideas?

1

Try this AppleScript:

tell application "Finder" to get name of every file of folder (path to applications folder)

Carlos figured this part out himself:

set appsPath to (path to applications folder)
tell application "Finder"

set appList to name of every application file of entire contents of folder appsPath end tell

| improve this answer | |
  • Thanks for the reply! Yeah, I think I should start using AppleScript for these types of things, though I have absolutely no experience on the subject. Unfortunately, this doesn't quite solve my problem - it lists all of the applications, yes, but only in the main Applications folder. It doesn't go into the subfolders, which is what I want it to do. The main problem is that when I tell automator to search the subfolders, it searches inside the App Containers as well... – Carlos Feb 24 '13 at 22:03
  • 1
    I've got it! Prompted by adayzones answer to my question, I began looking for applescript solutions to the problem... I didn't actually want to get out of Automator, as AppleScript is something I'm not familiar with, but the simplicity of the code adayzone recommended conviced me to give it a shot. I quickly found this discussion over in the Apple Support Communities with the solution: set appsPath to (path to applications folder) tell application "Finder" set appList to name of every application file of entire contents of folder appsPath end tell – Carlos Feb 24 '13 at 22:13
  • Aah, you beat me to it :D I also answered your questions. My AppleScript wasn't as simple :( so well done :) I would add this as an answer and mark it as the correct answer for other users to see. – Faiz Saleem Feb 24 '13 at 22:22
  • thanks for the reply! Yes, I wanted to do that (mark as reply) but it seems as I am a new user I can't answer my own question for the next 5 hours XD (also can't upvote your or adayzone's answers for now!) – Carlos Feb 24 '13 at 22:28
0

This AppleScript should search /Applications recursively and return a list of all the applications, just as adayzdone's AppleScript does. It doesn't search inside Application Containers - I've tested this myself. A downside is this does rely on Spotlight, and so if Spotlight is disabled, you won't get anything out of this. Not many people even disable Spotlight on a Mac anyway...but I ramble. Here's the code:

set ssRslt to (do shell script "mdfind -onlyin /Applications kMDItemFSName == '*.app'")
set {oldDelims, my text item delimiters} to {my text item delimiters, {return}}
set ssRslt to (text items of ssRslt)
set my text item delimiters to oldDelims
return ssRslt

In short, the script searches for /Applications files via Terminal, changes this to a list, and returns the result.

| improve this answer | |
  • Quick tip: set ssRslt to paragraphs of (do shell script...) – adayzdone Feb 24 '13 at 23:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .