I have a script I’ve been using for a few years based on one Christoper Stone posted here back in the day. It generates the version and build number of SD and Mac OS and puts them on the clipboard like this:
→ Script Debugger 8.0.1 (8A36)
→ Mac OS 11.6 (20G165)
This stopped working when I moved to SD8 because SD7 had been hard coded into the script.
I figured out how to get around that (easily) but looking at Chris’ code I realized I could make this work with any other application.
(So now it should work for SD 9 and SD 10 and SD11…)
I’m trying to figure out the best way to generate a list of which apps the user may want the versions for. Getting application processes from System Events takes forever, and only returns running apps. Contents of the application folders is a little quicker, but misses any apps not in those folders. Trying to get all apps would return all applets too. On my Mac that would be hundreds, if not thousands. (Some of our daily scripts are applets that get duplicated every day).
For now I’m thinking about making it a droplet that and storing previous apps.
Seems you can determine whether it’s an applet by checking its Info.plist's CFBundleExecutable.
This seems to work:
-- Get App URLs
-- Based on NigelGarvey's code (https://forum.latenightsw.com/t/searching-for-alias-files-recursively-not-descending-into-packages/1997/5)
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
set theFolderURL to current application's |NSURL|'s fileURLWithPath:"/Applications/"
set isPackageKey to current application's NSURLIsPackageKey
set theFileManager to current application's NSFileManager's defaultManager()
set allURLs to (theFileManager's enumeratorAtURL:theFolderURL includingPropertiesForKeys:{isPackageKey} options:((current application's NSDirectoryEnumerationSkipsPackageDescendants) + ((current application's NSDirectoryEnumerationSkipsHiddenFiles) as integer)) errorHandler:(missing value))'s allObjects()
set allAppAndAppletURLs to (allURLs's filteredArrayUsingPredicate:(current application's NSPredicate's predicateWithFormat:("self.path ENDSWITH " & quoted form of ".app")))
set allAppURLs to current application's NSMutableArray's new()
repeat with i from 0 to ((allAppAndAppletURLs's |count|()) - 1)
set thisURL to (allAppAndAppletURLs's objectAtIndex:i)
set thisBundle to (current application's NSBundle's bundleWithURL:thisURL)
set thisInfoDictionary to thisBundle's infoDictionary()
set thisCFBundleExecutable to (thisInfoDictionary's valueForKey:"CFBundleExecutable")
if not (thisCFBundleExecutable's isEqualTo:"applet") then
(allAppURLs's addObject:thisURL)
end if
end repeat
return allAppURLs