{"componentChunkName":"component---src-templates-post-template-js","path":"/powershell-expand-zipfile-en","result":{"data":{"markdownRemark":{"id":"23789687-acbd-54dd-9724-657eee9d8c56","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/powershell-expand-zipfile\">original page</a>.</p>\n</blockquote>\n<p>With the following command, you can expand all ZIP files in a folder, including subfolders, with PowerShell.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershel\"><pre class=\"language-powershel\"><code class=\"language-powershel\">Get-ChildItem -Path &#39;&lt;Folder Path&gt;&#39; -Recurse -Filter *.zip | ForEach-Object {\n    $destination = &quot;$($_.DirectoryName)\\$($_.BaseName)&quot;\n    Expand-Archive -Path $_.FullName -DestinationPath $destination -Force\n    Remove-Item -Path $_.FullName       \n}</code></pre></div>\n<p>I actually ran this script against a folder that contained multiple ZIP files in subfolders.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/5a31732a6d599aa185ce1598bfa214eb/4d383/image-20240108002832628.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 33.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsTAAALEwEAmpwYAAAA4ElEQVQoz5WRzW6EMBCDuUIgBEgI/xLiQglo3//p3HikXZU9bNuDNYplffEkybZtWNcVzlns+47rPBGOA9cVEELAcV6ir3CKDup6IEQvMMtMzHOe8Zy0bYuu627q+xbT6NHGS7SpoBuP0vYibTvo2sFE3xgjqqoKSilorZGUZYmiKGCtxTAMAnxewpnnOVSW3aUyAbxLgFkM1HWNaZowjqOA0zTFsiziMUTob3oBWZlA5xyapnk1I5iTGzD8ZyDXpUHgPM8yCWFbAn/CPoFvKz/fjw0pet77+Dm9PPp/Gn4DD5OrlZ1SauwAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/5a31732a6d599aa185ce1598bfa214eb/8ac56/image-20240108002832628.webp 240w,\n/static/5a31732a6d599aa185ce1598bfa214eb/d3be9/image-20240108002832628.webp 480w,\n/static/5a31732a6d599aa185ce1598bfa214eb/e46b2/image-20240108002832628.webp 960w,\n/static/5a31732a6d599aa185ce1598bfa214eb/2ccb3/image-20240108002832628.webp 1195w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/5a31732a6d599aa185ce1598bfa214eb/8ff5a/image-20240108002832628.png 240w,\n/static/5a31732a6d599aa185ce1598bfa214eb/e85cb/image-20240108002832628.png 480w,\n/static/5a31732a6d599aa185ce1598bfa214eb/d9199/image-20240108002832628.png 960w,\n/static/5a31732a6d599aa185ce1598bfa214eb/4d383/image-20240108002832628.png 1195w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/5a31732a6d599aa185ce1598bfa214eb/d9199/image-20240108002832628.png\"\n            alt=\"image-20240108002832628\"\n            title=\"image-20240108002832628\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>When you run the script, all ZIP files are deleted, and the folders containing the extracted files are expanded into the paths where the ZIP files were located.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ca002604b6cf0547ed8191a7e563c1ca/0a867/image-20240108003115345.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 89.16666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsTAAALEwEAmpwYAAABsUlEQVQ4y42U2Y6CQBREeVNBQHZBxSVO2Gb+//NqOG2umWQS4aHkNjanq243eNf7lx6Ph57Pp6qq0vF41DRNGsdR49DP9eDU9726YVQ3fqubfl6iHudrP2gYBnVdJy9NkjeoaRqdz2edTqeXmkrtpVZTl4qiWPtDpjCtFGbHl1w9K050OMz/7/fygiBQHMcKw9Apz3MVRfFWnhfz5IN839c+8BX4u/+aGSYPJxQGa9tW1+tVaZo6SF3XbsyizMPFJ3nEZSJu6BNjBNy5mifRhtVAHsINsZK5n4DLsnTOEDVizipglmUuLgOubA4CHkWRg+GYehWQHuISh0RDl8vFOdrtdi669ZAxD30Ce0wCxgO4okaAkN2zesmlhxM7Nlxxh4hJP+1MAgS8CKRfRKZHQNgIDjjwzWbjQLRhjTsHxBkr4xT46zDnb4d2n81ZgjkgK1tkbuCOiAAAM8b137gfN4XJFtneZwRgu92KY0VkFly1y4As8t+DbPEBUtOCVbvMj0Vmsh0XQMj6aG/TIpAjYl8cot5uN93vdwcjIvf4VrLI6l2mILq9hib7JNlhX+of+gX5SrAwhV10HgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ca002604b6cf0547ed8191a7e563c1ca/8ac56/image-20240108003115345.webp 240w,\n/static/ca002604b6cf0547ed8191a7e563c1ca/d3be9/image-20240108003115345.webp 480w,\n/static/ca002604b6cf0547ed8191a7e563c1ca/e46b2/image-20240108003115345.webp 960w,\n/static/ca002604b6cf0547ed8191a7e563c1ca/b508b/image-20240108003115345.webp 986w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ca002604b6cf0547ed8191a7e563c1ca/8ff5a/image-20240108003115345.png 240w,\n/static/ca002604b6cf0547ed8191a7e563c1ca/e85cb/image-20240108003115345.png 480w,\n/static/ca002604b6cf0547ed8191a7e563c1ca/d9199/image-20240108003115345.png 960w,\n/static/ca002604b6cf0547ed8191a7e563c1ca/0a867/image-20240108003115345.png 986w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ca002604b6cf0547ed8191a7e563c1ca/d9199/image-20240108003115345.png\"\n            alt=\"image-20240108003115345\"\n            title=\"image-20240108003115345\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>If you change the -Filter option in Get-ChildItem and the processing inside ForEach-Object, you can perform a wide variety of operations on arbitrary files in subfolders, so it looks like this could be useful in many different ways.</p>\n<p>After a quick search, I couldn’t find a script that matched my needs exactly, so I decided to put it together as a blog post.</p>","fields":{"slug":"/powershell-expand-zipfile-en","tagSlugs":["/tag/power-shell-en/","/tag/windows-en/","/tag/english/"]},"frontmatter":{"date":"2024-01-08","description":"How to expand all ZIP files in a folder, including subfolders, with PowerShell.","tags":["PowerShell (en)","Windows (en)","English"],"title":"Expanding All ZIP Files in a Folder, Including Subfolders, with PowerShell","socialImage":{"publicURL":"/static/f02f56ffc9130c18653c4f673f58711f/powershell-expand-zipfile.png"}}}},"pageContext":{"slug":"/powershell-expand-zipfile-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}