Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Merge and extract tgz files from Google Takeout

Recently found some clowny gist was the top result for 'google takeout multiple tgz', where it was using two bash scripts to extract all the tgz files and then merge them together. Don't do that. Use brace expansion, cat the TGZs, and extract:

$ cat takeout-20201023T123551Z-{001..011}.tgz | tar xzivf -

You don't even need to use brace expansion. Globbing will order the files numerically:

$ cat takeout-20201023T123551Z-*.tgz | tar xzivf -

tar has been around forever, they didn't design it to need custom scripts to deal with multipart archives. Since it's extracting the combined archive, there's no 'mess of partial directories' to be merged. It just works, as intended.

Copy link

shawnhank commented May 20, 2021

This worked very well for a 6TB Google Photos Takeout data set consisting of 22 50GB TGZ files. Ran it via Ubuntu on Windows (WSL) and the file total matched the export.

Proof positive that tar does indeed work!

Copy link

Jake-Je0n commented Jun 16, 2021

This really worked well. Thanks!

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