Skip to content

Instantly share code, notes, and snippets.

@seanburlington
Last active February 13, 2022 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanburlington/4f4e55de65397a00b94a41e3bd8ade33 to your computer and use it in GitHub Desktop.
Save seanburlington/4f4e55de65397a00b94a41e3bd8ade33 to your computer and use it in GitHub Desktop.
Google Photos Takeout Cleanup
#!/bin/bash
set -euo pipefail
find ~/Pictures -type f -printf "%f\n" | sort | uniq > ~/picture-names
cd /media/sean/Backup/burlington.me.uk-takeout
number=02
mkdir -p ~/Pictures/google-takeout/${number}
unzip takeout-20220208T164343Z-0${number}.zip
cd Takeout/Google\ Photos/
find . -name '*.json' -exec rm -v {} \;
# get rid of auto edited versions
find . -name '*-edited.*' -exec rm -v {} \;
find . -type f -printf "%f\n" | grep -vf ~/picture-names > missing-images.txt
while read in ; do find . -name "$in" >> missing-images-with-paths.txt; done < missing-images.txt
cat missing-images-with-paths.txt | while read in; do cp -v "$in" ~/Pictures/google-takeout/${number}; done
fdupes -r ~/Pictures/google-takeout/${number} --delete --noprompt
cd /media/sean/Backup/burlington.me.uk-takeout
rm -Rf Takeout/
@seanburlington
Copy link
Author

This is specific to my file structure

It will need editing

it's not perfect - but worked OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment