#!/bin/sh usage() { echo "" echo "Usage: $0 [-h | --help]" echo "" echo " -- Synchronize the modification date of a folder to match its latest madified content" echo " -- Special case, if it is an app bundle, in the case, where there is a Contents folder, its contnets are used instead to determine the date." echo " -- by alex - alex@farbflash.de" echo "" echo " -- first parameter => app bundle" } while [ "$1" != "" ]; do case $1 in -h | --help ) usage exit ;; * ) bundlePath=$1 esac shift done if [ -z "$bundlePath" ] then echo "Please specify a path to a Folder or App bundle as first parameter" exit fi if [ -d "$bundlePath/Contents" ] then absPathPath="$bundlePath/Contents" else absPathPath="$bundlePath" fi newestItem=$(stat -f "%m%t%Sm%t%N" "$absPathPath"/* | sort -rn | head -1 | cut -f2-) newestItemPath=$(echo "$newestItem" | cut -f2-) newestItemDate=$(echo "$newestItem" | cut -f-1) touch -r "$newestItemPath" "$bundlePath" echo "Changed date to $newestItemDate"