Created
October 9, 2019 08:59
-
-
Save vyder/350d758d15363b1c8c74f2583a094549 to your computer and use it in GitHub Desktop.
A ruby script to list 32-bit apps installed in macOS - in preparation of upgrading to macOS Catalina
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Run `gem install plist` to resolve the only dependency. | |
# | |
# This script creates two files in the directory that you run the script from | |
# | |
require 'plist' | |
require 'yaml' | |
RAW_FILENAME = "all_apps.plist" | |
APPS_LIST_FILENAME = "32bit-apps.yaml" | |
puts "Querying system_profiler..." | |
raw = %x(system_profiler -nospawn -xml SPApplicationsDataType -detailLevel full) | |
File.open(RAW_FILENAME, "w+") { |f| f.write(raw) } | |
puts "Parsing response..." | |
response = Plist.parse_xml(raw) | |
apps = response[0]["_items"] | |
apps_32bit = apps.select { |item| item["has64BitIntelCode"] == "no" }.sort_by { |item| item["_name"] } | |
output = apps_32bit.map do |app| | |
{ | |
"name" => app["_name"], | |
"path" => app["path"], | |
"from" => app["obtained_from"] | |
} | |
end | |
File.open(APPS_LIST_FILENAME, "w+") { |f| f.write(output.to_yaml) } | |
puts <<-EOF | |
Done. | |
Found #{apps_32bit.size} 32-bit app#{apps_32bit.size == 1 ? '' : 's'}. | |
Created files: | |
> #{APPS_LIST_FILENAME} | |
- Contains a list of 32-bit applications installed | |
> #{RAW_FILENAME} | |
- A plist (xml) with details of ALL applications installed | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment