23 lines
656 B
Bash
Executable File
23 lines
656 B
Bash
Executable File
#!/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
|