App and system versions

Crossposting from the ScriptDebugger forum, here’s a script, written with help from SD forum, that gathers the version and build info for the Mac OS and apps specified in the script by their bundle ids.

It sends the result to the clipboard when can be pasted as text in your post.

As always, any suggestions welcome.

→ Script Debugger 8.0.5 (8A61)
→ Script Editor 2.11 (225)
→ FastScripts 3.2.2 (1723)
→ Mac OS Version: 11.6.8 (Build 20G730)

use scripting additions
use framework "Foundation"

set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"Version ", "Build "}
set sysVer to (current application's NSProcessInfo's processInfo()'s operatingSystemVersionString())
set sysVer to text items 2 thru 3 of (sysVer as text)
set AppleScript's text item delimiters to {""}
set sysVer to {"-->  Mac OS Version: " & sysVer as text}

set allAppBundleIds to {¬
   ("com.latenightsw.ScriptDebugger8"), ¬
   ("com.red-sweater.fastscripts3") ¬
      }
-- You can include bundle identifier of app, as found in System events
--   ("com.apple.ScriptEditor2"), ¬

set appVersions to {}
repeat with thisAppBundleId in allAppBundleIds
   set the end of appVersions to GetAppInfo(thisAppBundleId)
end repeat

set versionStrings to {sysVer}
repeat with thisAppInfo in appVersions
   set {fullAppName, appVer, appBundleVer} to thisAppInfo
   set the end of versionStrings to "-->  " & fullAppName & space & appVer & " (" & appBundleVer & ")"
end repeat
set AppleScript's text item delimiters to {return}
set versionStrings to versionStrings as text
set AppleScript's text item delimiters to saveTID

set the clipboard to versionStrings

return the clipboard
-->  Script Debugger 8.0.5 (8A61)
-->  Script Editor 2.11 (225)
-->  FastScripts 3.2.2 (1723)
-->  Mac OS Version: 11.6.8 (Build 20G730)
on GetAppInfo(AppBundleId)
   set appNSURL to current application's NSWorkspace's sharedWorkspace()'s URLForApplicationWithBundleIdentifier:AppBundleId
   set appBundle to current application's NSBundle's bundleWithURL:appNSURL
   set fullAppName to (appBundle's infoDictionary()'s objectForKey:"CFBundleName") as text
   set appVer to (appBundle's infoDictionary()'s objectForKey:"CFBundleShortVersionString") as text
   set appBundleVer to (appBundle's infoDictionary()'s objectForKey:"CFBundleVersion") as text
   return {fullAppName, appVer, appBundleVer}
end GetAppInfo
 
1 Like