tell application "Aperture" to quit set new_file to choose file with prompt "Select Aperture Libary to compact its database" default location (path to pictures folder) of type {"BNDL"} set libname to (POSIX path of new_file) & "Aperture.aplib/" set dbname to libname & "Library.apdb" set sizeBefore to do shell script "ls -lah " & (quoted form of libname) & " | grep -E 'Library.apdb$' | awk {'print $5'}" do shell script "/usr/bin/sqlite3 " & (quoted form of dbname) & " vacuum" set sizeAfter to do shell script "ls -lah " & (quoted form of libname) & " | grep -E 'Library.apdb$' | awk {'print $5'}" display dialog ("Database before: " & sizeBefore & return & "Database after: " & sizeAfter & return & return & "Now try it out!")