#!/bin/bash

# Iterate through global Applications folder
applications_folder="/Applications"

# Check if the user has an Applications folder
if [ -d "$applications_folder" ]; then
    echo "Installed Applications:"
    for app in "$applications_folder"/*; do
        # Check if it's an application bundle
        if [ -d "$app" ] && [[ "$app" =~ .app$ ]]; then
            app_name=$(basename "$app")

            # Get the version from the Info.plist file
            info_plist="$app/Contents/Info.plist"
            if [ -f "$info_plist" ]; then
                app_version=$(defaults read "$info_plist" CFBundleShortVersionString)
            else
                app_version="Version information not found"
            fi
            echo "- $app_name ($app_version)"
        fi
    done
fi