#!/bin/sh
for D in */;
do
oldestnl=`find "$D" -type f -printf '%T+;%p\n' | sort | head -n 1`
oldest=`echo "$oldestnl" | tr -d '\n'`
fname="$(echo "$oldest" | cut -d';' -f2)"
fdate="$(echo "$oldest" | cut -d';' -f1)"
echo "$fdate $fname"
touch -m "$D" -r "$fname"
done
Sunday, 13 January 2019 00:00
Bash script to change modification time stamp on directories to that of the oldest file in the directory (for sorting MP3 albums for example)
Leave a comment
Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.