Created
December 25, 2021 12:07
-
-
Save lukashino/a6121dda4aca6c1816ddbc4b31301e26 to your computer and use it in GitHub Desktop.
# Add a missing timestamp to files with exiftool # This happened when I had multiple photos without datetimeoriginal timestamp set. It broke my gallery. # Little script adds timestamps to files that misses it but leaves it in files that has it already set. # How to use it # Place it in the folder where you have the photos/other files # chmod +x …
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 | |
# Add a missing timestamp to files with exiftool | |
# This happened when I had multiple photos without datetimeoriginal timestamp set. It broke my gallery. | |
# Little script adds timestamps to files that misses it but leaves it in files that has it already set. | |
# How to use it | |
# Place it in the folder where you have the photos/other files | |
# chmod +x efif-add-missing-ts.sh | |
# ./efif-add-missing-ts.sh . "2017:09:22 22:25:00" | |
# It creates copies of the original files (they can be removed with rm -rf *_original ) | |
# NOTICE: | |
# The first argument should signify the location of the files but the script needs to be still in the same folder as the files are. | |
if [[ $1 == "" ]]; then | |
echo "Specify location where images or movies" | |
elif [[ $2 == "" ]]; then | |
echo "Specify new timestamp \"2012:03:14 12:25:00\"" | |
fi | |
FILES_PATH=$1 | |
FILES=$(ls $FILES_PATH) | |
NEW_TS=$2 | |
for FILE in $FILES; do | |
echo "File: $FILE" | |
OUT=$(exiftool -q -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -common $FILE) | |
if [[ "$OUT" != "" ]]; then | |
echo "Changing dates of $FILE to $NEW_TS" | |
exiftool -AllDates="$NEW_TS" $FILE | |
else | |
echo "File $FILE already has timestamp set" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment