WinRAR command line to unzip files in multiple directories

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jymoo
Posts: 1
Joined: 29 Aug 2011 03:35

WinRAR command line to unzip files in multiple directories

#1 Post by jymoo » 29 Aug 2011 03:46

Hi Friends, I have created a batch file to unzip the zip files within multiple folders in a parent directory using WinRAR.

@echo off

FOR /D /r %%G in (*) DO if exist %%G\*.zip C:\progra~1\WinRAR\Winrar.exe e %%G\*.zip %%G\

pause
exit


How it works
This works, and the files are extracted to the same folder. For example, I have a parent folder by name Parent, a subfolder by name Child and under that, a zip file by name zipfile.zip. This batch extracts the files in the zip file into the folder Child. This works in any given parent and child folder.

What I expect
I wish the batch to create a folder by name zipfile (the variable name of the zip file) within the Child folder. The files should be extracted into the newly created folder. This hsould work in any given parent and child folders.

I had tried the X command instead of the E in the command line, however, it doesnt seem to help. When we select multiple zip files and right-click, a WinRAR command is available to extract each archive to a separate folder. I need something of that sort to work for zip files across multiple folders, yet retaining the tree structure.

Thank you in advance. I know you guys are very very smart and will solve it in no time.

Post Reply