Skip to content

Instantly share code, notes, and snippets.

@joeperpetua
Created January 8, 2024 12:23
Show Gist options
  • Save joeperpetua/c41a203b1c00b92d10dd8c46bd068de8 to your computer and use it in GitHub Desktop.
Save joeperpetua/c41a203b1c00b92d10dd8c46bd068de8 to your computer and use it in GitHub Desktop.
#!/bin/bash
####
# Usage
# ./increment_subdir_mtime.sh "path/to/parent/folder" increment_in_seconds:INT
# eg:
# ./increment_subdir_mtime.sh "/volume1/DATA/" 5
####
TARGET_PATH=$(realpath "$1")
INCREMENT=$2
for folder in $(find "$TARGET_PATH" -mindepth 1 -type d)
do
current_mtime=$(stat -c %Y "$folder")
let "new_mtime = current_mtime + $INCREMENT"
touch -t $(date -d "@$new_mtime" +%Y%m%d%H%M.%S) "$folder"
done
@joeperpetua
Copy link
Author

Usage:

./increment_subdir_mtime.sh "path/to/parent/folder" increment_in_seconds:INT

eg:

./increment_subdir_mtime.sh "/volume1/DATA/" 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment