简体   繁体   中英

How to use Windows Batch File to mass unzip files and saving them in specific folders?

I got the code to mass unzip from this link . But it unzips everything in the folder where the batchfile exists. I want it to unzip it to specific folders or its individual folders.

Note: my bz2 files are in various folders outside the folder where the batchfile exists.

Here's the script that i used :

for /R "C:\Users\victor\Desktop\MASTERS\color feret\disc 1\data\images" %%I in ("*.bz2")
do ("%ProgramFiles%\WinRAR\WinRAR.exe" x -y -o"%%~dpnI" "%%~fI")

Can someone enlighten me how to do it? And also if possible, can anyone explain to me what are the arguments for? "x , -y -o %%dpnI " etc. Thanks

You do not need a batch file for this process at all. Start WinRAR , select all the archives you want to extract, click on Extract To in toolbar, select the base destination folder, check the option Extract archives to subfolders in Miscellaneous group and press button OK. That's it.

From a command line in a console window with current working directory being the directory containing all the *.bz2 files to extract:

"%ProgramFiles%\WinRAR\WinRar.exe" x -ad -y *.bz2 C:\Temp\

There is no need for a for loop as WinRAR supports wildcards for archive file names.

And with option -ad the archive file First.bz2 is extracted to folder C:\\Temp\\First , archive file Other.bz2 is extracted to C:\\Temp\\Other , and so on. With checking option Extract archives to subfolders in GUI, you use option -ad .

Help of WinRAR contains the page Switch -AD - append archive name to destination path . Click in menu Help on Help topics . On tab Contents open Command line mode and open Commands and Switches . Also text file Rar.txt in program files folder of WinRAR contains a description for command x and the options -ad and -y and all other commands and options for console version Rar.exe .

But if you want to use nevertheless a for loop and want to know what %%~dpnI and %%~fI mean, open a command prompt window, enter either help for or for /? and read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM