{"id":337,"date":"2023-02-04T15:53:08","date_gmt":"2023-02-04T07:53:08","guid":{"rendered":"https:\/\/www.ddzheng.cc\/?p=337"},"modified":"2026-01-13T20:45:02","modified_gmt":"2026-01-13T12:45:02","slug":"a-script-to-recursively-extract-nested-zip-files","status":"publish","type":"post","link":"https:\/\/www.ddzheng.cc\/?p=337","title":{"rendered":"A script to recursively extract nested zip files"},"content":{"rendered":"\n<p>A simple shell script to recursively extract nested zip files (zip files inside zip files), extracts each zip file to a folder with same name at the location of the zip file and retaining directory structure.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/connorzheng97\/525ab44ede56d81e8aa2d033f9365a68.js\"><\/script>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a.zip\n|-1.zip\n| |-baz.mp3\n|-foo.txt\n|-bar.jpg\nb.zip\n|-2.zip\n| |-hello.txt\n|-world.txt<\/code><\/pre>\n\n\n\n<p>After extraction will become:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a\n|-1\n| |-baz.mp3\n|-foo.txt\n|-bar.jpg\nb\n|-2\n| |-hello.txt\n|-world.txt<\/code><\/pre>\n\n\n\n<p>The script loop through all zip files, extracting them into a folder with the name of the zip file, then delete the zip file.<\/p>\n\n\n\n<p>Note this may not work well with paths with special characters. Also this script delete each zip file once it&#8217;s successfully unzipped. If this behavior is undesirable change the <code>rm<\/code> command to a <code>mv<\/code> command. <\/p>\n\n\n\n<p>Add <code>-o<\/code> option to <code>unzip<\/code> command to overwrite existing files. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A simple shell script to recursively extract nested zip files, extracts each zip file to its own folder and retaining directory structure.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[27,28,14],"class_list":["post-337","post","type-post","status-publish","format-standard","hentry","category-tech","tag-linux","tag-script","tag-software"],"_links":{"self":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337"}],"version-history":[{"count":5,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions"}],"predecessor-version":[{"id":1193,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions\/1193"}],"wp:attachment":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}