#!/bin/sh # Set modification date of the current (or specified) directory # to the earliest file in that directory. # # License: LGPLv2 # # I use this when I don't want to record when I (re)filed something, # and would like the directories to be ordered by date of the contents. # Digital camera pictures is usually what I use this for. [ -z "$1" ] && set "." file=`find $1 -maxdepth 1 -type f -printf "%p\t%T@\n" | sort -k2,2n | head -1 | cut -f1` [ -z "$file" ] && exit filedate=`date --reference="$file" +%y%m%d%H%M` touch -c -t $filedate $1