-
-
Save judzi/981eae8117f80d2bf7bb0a08050889d8 to your computer and use it in GitHub Desktop.
#!/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.zip" | |
if [ ! -f "$f" ]; then | |
echo "Archive not found: $f. Skipping ... " | |
continue | |
fi | |
mkdir -p $p | |
cd $p | |
echo "Unzipping takeout-${archiveTimestamp}-$p.zip ..." | |
unzip "../takeout-${archiveTimestamp}-$p.zip" | |
echo "DONE unzipping $p" | |
cd .. | |
done | |
echo "ALL UNZIPPED!" |
Why would you need a script (or in your case two) for this? Use brace expansion, cat the TGZs, and extract:
cat takeout-20201023T123551Z-{001..011}.tgz | tar xzivf -
They were zip files.
Just this works:
unzip '*.zip' -d complete-takeout
Usage:
Given a directory with this file pattern:
./takeout-20181016T122422Z-001.tgz
./takeout-20181016T122422Z-002.tgz
./takeout-20181016T122422Z-003.tgz
Then we call these commands:./takeout-unzip.sh 3 20181016T122422Z
./takeout-merge.sh 3
And everything will be merged under ./../Takeout-merge
Dear, author. I am completely lost, zero, nothing in programming. I just need to merge and extract all the data from my drive and I found this page which I believe would solve my issue. But I have no idea how to do this. Can you elaborate it a little bit more for me in terms what tools to use, how to operate, etc. Any help will be so much appreciated. Thanks in advance!
There is an Bug in rsync line: {$destDir} -> ${destDir}
@MarkusKress you do not need to use this script at all. See https://gist.github.com/chabala/22ed01d7acf9ee0de9e3d867133f83fb
Why would you need a script (or in your case two) for this? Use brace expansion, cat the TGZs, and extract:
cat takeout-20201023T123551Z-{001..011}.tgz | tar xzivf -
This worked like a charm, even on Windows using Git bash 👍
Usage:
Given a directory with this file pattern:
./takeout-20181016T122422Z-001.tgz
./takeout-20181016T122422Z-002.tgz
./takeout-20181016T122422Z-003.tgz
Then we call these commands:
./takeout-unzip.sh 3 20181016T122422Z
./takeout-merge.sh 3
And everything will be merged under ./../Takeout-merge