From b51452d53e5f41b1348fb795428fb4003a5a0652 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Wed, 20 Nov 2024 11:22:26 +0200 Subject: [PATCH] add dir times fix --- fix_dir_dates.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 fix_dir_dates.sh diff --git a/fix_dir_dates.sh b/fix_dir_dates.sh new file mode 100644 index 0000000..a5c110b --- /dev/null +++ b/fix_dir_dates.sh @@ -0,0 +1,8 @@ +#!/bin/bash +while read -r dir +do + last_file=$(ls -- "${dir}" -ht | head -n1) + last_file_time=$(stat -c %Y -- "${last_file}") + last_file_time_formated=$(date -d "@${last_file_time}" +%Y%m%d%H%M.%S) + touch -a -m -t "${last_file_time_formated}" -- "${dir}" +done <<< "$(find . -mindepth 1 -maxdepth 1 -type d)"