[Bat + PowerShell] A method to decompress and unzip multiple zip files at once.You can copy the code immediately without installing the software!


Hello!This time, I would like to introduce how to combine batch files and PowerShell to decompress multiple Zip files at once.

Zip files are one of the most well-known formats for compressing files and folders.
Until a long time ago, it was necessary to install special software to compress and decompress files.

However, most operating systems now have the ability to decompress as standard.
Even on Windows, you can see the contents by double-clicking the Zip file.

However, it is not possible to execute the program inside the Zip file or the program that refers to it.

If it is a PC or a person's thing that is not connected to the Internet, it is difficult to install the software.
How about using this method as a method of decompressing files using standard functions that are useful in such cases?

Thing you want to do

If you have only one Zip file, you can "right-click" and "extract all".It's not that difficult either.

But if you have a lot of files, it's very annoying to do them one by one, right? If it exceeds XNUMX, it will be a pain.

In such a case, please copy the code below and make a batch.

Script example

@echo off
cd /d %~dp0

dir /b /s *.zip>%~dp0zips.txt

for /f %%a in (%~dp0zips.txt) do (
powershell -command "Expand-Archive -Path %%a -DestinationPath %%~na"

How to use

1. Combine Zip files into one folder

2. Put the batch file created earlier in that folder

3. Double-click the batch file to execute it

Then, the unzipped file will be created in the same folder!


Get a list of Zip files in text

① "dir /b /s*.zip>%~dp0zips.txt"

This command outputs a list of file names with the extension zip in the same folder as the created batch to the "zips.txt" file in the same folder.

The "dir" command is explained in detail on the following page.Please refer to it if you like.

Pass the file list of text files to the decompression command one by one

② "for / f %% a in ('% ~ dp0zips.txt') do (powershell -command"Expand Archive -Path %% a -DestinationPath %% ~ na ")"

Command to read line by line from the text file of "ZIP file file name list" created in (1) above and decompress (decompress) the PowerShell file."Expand-Archive"It is decompressed (decompressed) with.


This time, in PowerShell"Expand-Archive"I introduced how to decompress multiple Zip files using.

If you look it up on the net, you can download software that can decompress a lot of "ZIP" at once.It's definitely easier to use such software for personal use.

The trouble of installing software and ensuring the safety of connecting to a network can be a life-and-death problem for people who play with PCs in business.Also, because it is a company loaned PC, I can't install the software without permission, but there are a lot of ZIP files!In some cases.

However, the true value of this method is when you want to decompress the ZIP with a command.
If you can do this with batch or powershell, you can save space when backing up files, copying files, etc.

I hope it helps you.


Translate »
I copied the title and URL