Last active
November 23, 2020 03:55
-
-
Save davidschlachter/b7a413d667d6adfbbca01f8748186015 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 | |
if [ $# -eq 0 ] | |
then | |
echo "Usage: set-months.sh YEAR" | |
fi | |
export YEAR=$1 | |
exiftool -overwrite_original "-alldates=${YEAR}:01:01 15:00:00" *JANUARY.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:02:01 15:00:00" *FEBRUARY.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:03:01 15:00:00" *MARCH.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:04:01 15:00:00" *APRIL.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:05:01 15:00:00" *MAY.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:06:01 15:00:00" *JUNE.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:07:01 15:00:00" *JULY.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:08:01 15:00:00" *AUGUST.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:09:01 15:00:00" *SEPTEMBER.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:10:01 15:00:00" *OCTOBER.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:11:01 15:00:00" *NOVEMBER.jpg | |
exiftool -overwrite_original "-alldates=${YEAR}:12:01 15:00:00" *DECEMBER.jpg | |
for MONTH in JANUARY JAN FEBRUARY FEB MARCH MAR APRIL APR MAY JUNE JUN JULY JUL AUGUST AUG SEPTEMBER SEP SEPT OCTOBER OCT NOVEMBER NOV DECEMBER DEC; do | |
regex_pattern="${MONTH} ([0-9]+).jpg" | |
find . -name "*${MONTH} [0-9]*.jpg" | while read line; do | |
if [[ $line =~ $regex_pattern ]]; then | |
#echo "$line" | |
#echo "${BASH_REMATCH[1]}" | |
DAY="${BASH_REMATCH[1]}" | |
NMONTH=$(gdate --date="$(printf "01 %s" "01 ${MONTH}")" +"%m") | |
#echo "$NMONTH" | |
if [[ $DAY -lt 32 ]]; then | |
exiftool -overwrite_original "-alldates=${YEAR}:${NMONTH}:${DAY} 15:00:00" "$line" | |
else | |
echo " ERROR: Invalid date" | |
echo "$line" | |
fi | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment