#!/bin/sh . "${HOME}/.mac_scripts" die () { echo An error has occured. exit $1 } while [[ ${#*} -ne 0 ]] ; do d="${1}" shift [[ "${d:((${#d}-1))}" == "/" ]] && d="${d:0:((${#d}-1))}" [[ "$d" == "" ]] && continue [[ ! -d "$d" ]] && continue echo $d mdls -name kMDItemContentTypeTree "$d" | grep "com.apple.package">/dev/null && t="${d%.*}" || t="$d" tar -cvjf "$t.tbz" "$d" || die $? tar -tzf "$t.tbz" || die $? rm -rf "$d" || die $? done