Created
August 12, 2024 08:14
Signal media comes without metadata (which is good). But for importing into photo apps, it makes sense to have at least date and time, which is in the filename anyway.
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 | |
for file in signal-*.jpeg signal-*.mp4; do | |
filename=$(basename "$file") | |
date_time=$(echo "$filename" | cut -d '-' -f 2-5 | sed 's/_/ /g' | sed 's/-/ /g' | awk '{print $1 "-" $2 "-" $3 " " $4}' | sed 's/ /:/4') | |
# Add metadata to images and videos | |
if [[ $file == *.jpeg ]]; then | |
exiftool -overwrite_original -DateTimeOriginal="$date_time" -DateTimeDigitized="$date_time" -DateTime="$date_time" "$file" | |
elif [[ $file == *.mp4 ]]; then | |
exiftool -overwrite_original -MediaModifyDate="$date_time" -MediaCreateDate="$date_time" -TrackModifyDate="$date_time" -TrackCreateDate="$date_time" "$file" | |
fi | |
# Convert date_time to touch format | |
touch_date_time=$(date -j -f "%Y-%m-%d %H%M%S" "$date_time" "+%Y%m%d%H%M.%S") | |
# Change the modified time of the file | |
touch -t "$touch_date_time" "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment