Created
January 8, 2024 12:23
-
-
Save joeperpetua/c41a203b1c00b92d10dd8c46bd068de8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
./increment_subdir_mtime.sh "path/to/parent/folder" increment_in_seconds:INT
eg:
./increment_subdir_mtime.sh "/volume1/DATA/" 5