Created
May 24, 2022 11:59
-
-
Save thomaswitt/14f64ceea0142bb9a12e1b1a7fbfcb5c to your computer and use it in GitHub Desktop.
Take an Instagram data export, use metadata from media.json file, rename pictures and add EXIF/IPTC date and title, so they're ready to import in a photo management application like iPhoto
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 [[ ! -s "media.json" ]]; then | |
echo "*** ERROR: No media.json file in current directory" | |
exit 1 | |
fi | |
mkdir result | |
echo -n "Processing " | |
for row in $(cat media.json | jq -r '.[][] | @base64'); do | |
_jq() { | |
echo ${row} | base64 --decode | jq -r ${1} | |
} | |
P_PATH=$(_jq '.path') | |
P_TAKEN_AT=$(_jq '.taken_at') | |
P_CAPTION=$(_jq '.caption') | |
P_FILENAME=$(date -u -j -f "%Y-%m-%dT%H:%M:%S+00:00" "${P_TAKEN_AT}" +"%Y-%m-%d-%H%M%S") | |
P_EXT=`echo "$P_PATH" | cut -d'.' -f2` | |
exiftool -q \ | |
-AllDates="${P_TAKEN_AT}" \ | |
-SpecialInstructions= \ | |
-iptc:Caption-Abstract="${P_CAPTION}" \ | |
-iptc:Keywords="Instagram" \ | |
-iptc:ObjectName="${P_CAPTION}" \ | |
-iptc:OriginatingProgram='Instagram' \ | |
-iptc:codedcharacterset=utf8 \ | |
-o "result/${P_FILENAME}.${P_EXT}" \ | |
${P_PATH} | |
if [ $? -ne 0 ]; then | |
echo " - ERROR in result/${P_FILENAME}.${P_EXT} (from ${P_PATH})\n" | |
else | |
echo -n "." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment