#!/bin/bash

adjust_recursively() {
    local path="$1"
    local current_dir=
    while read DIR ; do
        #current_dir="$path/$DIR"
        current_dir="$DIR"
        echo "=> Entering $current_dir" >&2
        # Adjust in depth...
        adjust_recursively "$current_dir"
        # Adjust current_dir
        last_file="${current_dir}/$(ls -rt $current_dir | tail -1)"
	    mtime=$(stat -c %y "$last_file")
        echo "   \=> Using $last_file [$(cut -d. -f1 <<<"$mtime")]" >&2
	    touch -d"$mtime" "$current_dir"
    done < <(find "$path" -mindepth 1 -maxdepth 1 -type d)
}

adjust_recursively .

# vim:set ts=4 et ai: #
