Skip to content

Instantly share code, notes, and snippets.

@jhelmink
Created February 4, 2024 00:34
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 jhelmink/f89a9897b85a3adb9b791b7ebae59417 to your computer and use it in GitHub Desktop.
Save jhelmink/f89a9897b85a3adb9b791b7ebae59417 to your computer and use it in GitHub Desktop.
WSL Script to Merge Google Takeout Photos from multiple zips. Excludes the .json files.
# Run in the folder with all your extracted zips
# IMPORTANT: Edit this using LF end of line sequence in Visual Studio Code
# To make it executable; chmod +x takeout-merge.sh
# To run; ./takeout-merge.sh
# Set destination folder
destDir="./takeout-merge"
mkdir $destDir
# Merge all folders
for d in ./*
do
if [ -d "$d" ]; then
echo "Processing $d"
if [ "$d" = "$destDir" ]; then
echo "Skipping $d, it's the destination folder. "
continue
fi
if [ -f $d/MergeComplete.txt ]; then
echo "Skipping $d, already merged. "
continue
fi
if [ ! -d "$d/Takeout" ]; then
echo "Skipping $d, no Takeout folder. "
continue
fi
echo "Merging $d/Takeout into $destDir ... "
# r = recursive on folders
# t = preserve modification times
# X = preserved extended attributes
# h = output numbers in a human-readable format
# u = skip files which are newer in dest than in src
# exclude the .json files
rsync -rtXhu --info=progress2 --safe-links --exclude=*.json $d/Takeout $destDir
touch "$d/MergeComplete.txt" # mark as merged
echo "DONE merging $d/Takeout into $destDir."
fi
done
# Reset all the completed status using;
# find . -name "MergeComplete.txt" -type f -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment