This commit is contained in:
2022-01-07 18:07:25 -08:00
parent a9590c0dce
commit bab7810cd3
22 changed files with 114606 additions and 1 deletions

23
bin/file-by-date Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -x
for FN in *; do
if [[ -f "$FN" ]]; then
MTIME="$(stat -f "%Sm" "$FN")"
if [[ ! -z "$MTIME" ]]; then
# eg "Sep 13 05:02:26 2019"
YYYY="$(date -j -f "%b %d %T %Y" "$MTIME" "+%Y")"
MM="$(date -j -f "%b %d %T %Y" "$MTIME" "+%m")"
DD="$(date -j -f "%b %d %T %Y" "$MTIME" "+%d")"
TD="${YYYY}/${YYYY}-${MM}/${YYYY}-${MM}-${DD}"
if [[ ! -d ./"$TD" ]]; then
mkdir -p ./"$TD"
fi
if [[ ! -e ./"${TD}"/"$FN" ]]; then
mv ./"$FN" ./"$TD"/"$FN"
echo mv ./"$FN" ./"$TD"/"$FN"
fi
fi
fi
done

22
bin/rename-images-by-mtime Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
set -x
for FN in *.jpg *.png *.jpeg *.heic *.gif *.GIF *.JPG *.PNG *.JPEG *.HEIC; do
if [[ -e "$FN" ]]; then
MTIME="$(stat -f "%Sm" "$FN")"
if [[ ! -z "$MTIME" ]]; then
# eg "Sep 13 05:02:26 2019"
NP="$(date -j -f "%b %d %T %Y" "$MTIME" "+%Y-%m-%dT%H%M%S")"
EXT="${FN##*.}"
LOWEREXT="$(echo "$EXT" | tr 'A-Z' 'a-z')"
TARGET="$NP.$LOWEREXT"
if [[ -e "$FN" ]]; then
if [[ ! -e "$TARGET" ]]; then
mv "$FN" "$TARGET"
echo mv "$FN" "$TARGET"
fi
fi
fi
fi
done