Tutorial

Nuevas actualizaciones y mejoras para Roundfleet.

Aviso importante

Los ejemplos de código y scripts proporcionados en estos tutoriales son solo para propósitos educativos. Roundfleet no es responsable de ningún problema, daño o vulnerabilidad de seguridad que pueda surgir del uso, modificación o implementación de estos ejemplos. Siempre revisa y prueba el código en un entorno seguro antes de usarlo en sistemas de producción.

Get Application Path on macOS

Learn how to find and retrieve application installation paths on Mac devices using scripts. This is essential for application management, script deployment, and allowlist/blocklist configuration.

Basic App Path Finder

Find the path of an application using its bundle identifier:

#!/bin/bash

# Specify the bundle ID
BUNDLE_ID="com.apple.Safari"

# Find app path using mdfind
APP_PATH=$(mdfind "kMDItemCFBundleIdentifier=='${BUNDLE_ID}'")

if [[ -n "$APP_PATH" ]]; then
    echo "Application path: $APP_PATH"
else
    echo "Application not found: $BUNDLE_ID"
fi

Enhanced Path Discovery

Script with validation and multiple search methods:

#!/bin/bash

# Function to find app path
find_app_path() {
    local bundle_id="$1"
    
    # Method 1: Use mdfind with bundle identifier
    local app_path=$(mdfind "kMDItemCFBundleIdentifier=='${bundle_id}'" | head -1)
    
    if [[ -n "$app_path" && -d "$app_path" ]]; then
        echo "$app_path"
        return 0
    fi
    
    # Method 2: Search common directories
    local common_paths=(
        "/Applications"
        "/System/Applications"
        "/Applications/Utilities"
        "/System/Library/CoreServices"
    )
    
    for path in "${common_paths[@]}"; do
        if [[ -d "$path" ]]; then
            local found=$(find "$path" -name "*.app" -maxdepth 2 -exec defaults read {}/Contents/Info.plist CFBundleIdentifier \; -print 2>/dev/null | grep -B1 "^${bundle_id}$" | grep "\.app$")
            if [[ -n "$found" ]]; then
                echo "$found"
                return 0
            fi
        fi
    done
    
    return 1
}

# Example usage
BUNDLE_ID="${1:-com.apple.Safari}"

echo "Searching for application: $BUNDLE_ID"

if APP_PATH=$(find_app_path "$BUNDLE_ID"); then
    echo "Found application at: $APP_PATH"
    
    # Get additional info
    APP_NAME=$(defaults read "$APP_PATH/Contents/Info.plist" CFBundleName 2>/dev/null)
    APP_VERSION=$(defaults read "$APP_PATH/Contents/Info.plist" CFBundleShortVersionString 2>/dev/null)
    
    echo "Application Name: ${APP_NAME:-Unknown}"
    echo "Version: ${APP_VERSION:-Unknown}"
else
    echo "Application not found: $BUNDLE_ID"
    exit 1
fi

Multiple App Path Finder

Find paths for multiple applications at once:

#!/bin/bash

# Array of bundle IDs to search for
BUNDLE_IDS=(
    "com.apple.Safari"
    "com.apple.finder"
    "com.apple.systempreferences"
    "com.microsoft.Excel"
    "com.adobe.Photoshop"
)

# Function to find app path
find_app_path() {
    local bundle_id="$1"
    mdfind "kMDItemCFBundleIdentifier=='${bundle_id}'" | head -1
}

echo "=== Application Path Report ==="
echo "Generated: $(date)"
echo "Device: $(hostname)"
echo "================================"

for bundle_id in "${BUNDLE_IDS[@]}"; do
    echo "Searching: $bundle_id"
    
    app_path=$(find_app_path "$bundle_id")
    
    if [[ -n "$app_path" && -d "$app_path" ]]; then
        echo "  ✓ Found: $app_path"
        
        # Get app version if available
        version=$(defaults read "$app_path/Contents/Info.plist" CFBundleShortVersionString 2>/dev/null)
        if [[ -n "$version" ]]; then
            echo "  📦 Version: $version"
        fi
    else
        echo "  ✗ Not found"
    fi
    echo
done

Bundle ID Discovery

Find bundle IDs of installed applications:

#!/bin/bash

echo "=== Installed Applications Bundle IDs ==="

# Search in common application directories
SEARCH_PATHS=(
    "/Applications"
    "/System/Applications"
    "/Applications/Utilities"
)

for search_path in "${SEARCH_PATHS[@]}"; do
    if [[ -d "$search_path" ]]; then
        echo "Scanning: $search_path"
        
        find "$search_path" -name "*.app" -maxdepth 2 | while read app_path; do
            app_name=$(basename "$app_path" .app)
            bundle_id=$(defaults read "$app_path/Contents/Info.plist" CFBundleIdentifier 2>/dev/null)
            
            if [[ -n "$bundle_id" ]]; then
                echo "  $app_name -> $bundle_id"
            fi
        done
        echo
    fi
done

Usage with Roundfleet

  1. Modify the BUNDLE_ID variable with your target application
  2. For multiple apps, update the BUNDLE_IDS array
  3. Deploy through Roundfleet's remote script execution
  4. View results in the action history

Common Bundle IDs

ApplicationBundle ID
Safaricom.apple.Safari
Findercom.apple.finder
System Preferencescom.apple.systempreferences
Microsoft Wordcom.microsoft.Word
Google Chromecom.google.Chrome
Firefoxorg.mozilla.firefox
Slackcom.tinyspeck.slackmacgap
Zoomus.zoom.xos

Troubleshooting

No results found: Verify the bundle ID is correct and application is installed Multiple paths returned: Use head -1 to get the first result or filter by specific location Permission denied: Ensure script has necessary file system access permissions


Note: Bundle IDs are case-sensitive. Use the exact format as provided by the application developer.