From 9a7d05ba77f2d95de9504462cf883c2f4316f1b1 Mon Sep 17 00:00:00 2001 From: menzel Date: Wed, 25 Feb 2026 10:12:24 +0100 Subject: [PATCH] first attempt for fix_dir_mtime.py, plus some minor changes --- .gitignore | 13 ++++++++++++ fix_dir_mtime.py | 34 ++++++++++++++++++++++++++++++++ openai/{openai.py => ChatGPT.py} | 0 3 files changed, 47 insertions(+) create mode 100644 .gitignore create mode 100755 fix_dir_mtime.py rename openai/{openai.py => ChatGPT.py} (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..672e55d --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Python +__pycache__/ +*.pyc +*.pyo +*.pyd +.pytest_cache/ + +# Editors / OS +.DS_Store + +# Optional: local scratch +*.tmp +*.swp diff --git a/fix_dir_mtime.py b/fix_dir_mtime.py new file mode 100755 index 0000000..3e6f457 --- /dev/null +++ b/fix_dir_mtime.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import os +import sys +from pathlib import Path + + +def update_dir_mtime(path: Path): + if not path.is_dir(): + return path.stat().st_mtime + + newest = 0 + + for child in path.iterdir(): + if child.is_dir(): + child_mtime = update_dir_mtime(child) + else: + child_mtime = child.stat().st_mtime + + newest = max(newest, child_mtime) + + if newest > 0: + os.utime(path, (newest, newest)) + + return max(newest, path.stat().st_mtime) + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: fix_dir_mtime.py ") + sys.exit(1) + + root = Path(sys.argv[1]).resolve() + update_dir_mtime(root) diff --git a/openai/openai.py b/openai/ChatGPT.py similarity index 100% rename from openai/openai.py rename to openai/ChatGPT.py