List all applications - output as text file

后端 未结 4 913
南方客
南方客 2021-01-01 07:21

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 applicatio

相关标签:
4条回答
  • 2021-01-01 08:05

    For poeple like me using bash scripting to reach their goals here is a bash variant of the script:

    #!/usr/bin/env bash
    
    path='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support'
    $path/lsregister -dump | grep -A 1 "^bundle" | grep --only-matching "/.*\.app" | awk -F "/" '{ print $NF }' | awk -F "." '{ print $1 }'
    

    This gives a list of all apps without the .app extension.

    0 讨论(0)
  • 2021-01-01 08:10

    I use the system_profiler command to get my text. Then you can parse as needed.

    system_profiler SPApplicationsDataType
    

    ...

    AppleScript Utility:
    
      Version: 1.1.1
      Last Modified: 5/18/09 10:34 PM
      Kind: Intel
      64-Bit (Intel): Yes
      Location: /System/Library/CoreServices/AppleScript Utility.app
    

    maybe pipe it to a text file and then use sed ....

    Bash commands can be called through applescript if you want to have an application or you can save the script with a .command extension and the user will be able to double-click on it.

    0 讨论(0)
  • 2021-01-01 08:20

    There are a few methods in this post, depending on how in-depth you want your search to be. Also not sure if that's exactly the output format you want, but you can probably tweak it for your specific needs.

    0 讨论(0)
  • 2021-01-01 08:21

    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
    
    0 讨论(0)
提交回复
热议问题