Skip to content

Instantly share code, notes, and snippets.

@jacob-faber
Created November 12, 2019 07:48
Show Gist options
  • Save jacob-faber/b9dd2e2099a731dc781af862215feed6 to your computer and use it in GitHub Desktop.
Save jacob-faber/b9dd2e2099a731dc781af862215feed6 to your computer and use it in GitHub Desktop.
Google Takeout Merge Tool: Unzips and merges all your exported data into a single folder
#!/usr/bin/env bash
destDir="../Takeout-merge"
mkdir -p $destDir
# Merges the different unzipped Takeout folders into one
for p in $(seq -f "%03g" 1 ${1:-1}); do
if [ -f $p/DONE ]; then
echo "Skipping $p/Takeout ... "
continue
fi
echo "Merging $p/Takeout into {$destDir} ... "
# t = preserve modification times
# q = quiet, suppress non-error messages
# r = recursive on folders
# X = preserved extended attributes
# X = skip files which are newer in dest than in src
# h = output numbers in a human-readable format
rsync -rtXhu --info=progress2 --safe-links --remove-source-files $p/Takeout {$destDir}
touch "$p/DONE"
echo "DONE merging $p"
done
echo "ALL MERGED!"
#!/usr/bin/env bash
# Unzips all Takeout archive files (living in the same dir)
archiveTimestamp=${2:-"20000101T100000Z"}
for p in $(seq -f "%03g" 1 ${1:-1}); do
f="takeout-${archiveTimestamp}-$p.tgz"
if [ -f $f ]; then
echo "Archive not found: $f. Skipping ... "
continue
fi
mkdir -p $p
cd $p
echo "Unzipping takeout-${archiveTimestamp}-$p.tgz ..."
tar -zxf "takeout-${archiveTimestamp}-$p.tgz"
echo "DONE unzipping $p"
cd ..
done
echo "ALL UNZIPPED!"
@jacob-faber
Copy link
Author

Nice 👍

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