Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In windows, I would like to use some sort of batch file to unzip files on multiple directory at once.

For example :

Initial directory

--Foo1

----file1.zip

--Foo2

----Foo2.zip

The script would run with the Foo as the initial directory and search for the available sub directory and extract all the files on theses directory.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You want the FOR command with the /R parameter:

FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]

    Walks the directory tree rooted at [drive:]path, executing the FOR
    statement in each directory of the tree.  If no directory
    specification is specified after /R then the current directory is
    assumed.  If set is just a single period (.) character then it
    will just enumerate the directory tree.

Type help for at the Command Prompt for full details on usage.

And remember, if using variables in a script you need to use %% instead of %.

share|improve this answer

Here is how I did it :

@setlocal
@echo off
set path="C:\Program Files\WinRAR\";%path%
for /F %%i in ('dir /s/b *.rar') do call :do_extract "%%i"
goto :eof

:do_extract
echo %1
mkdir %~1.extracted
pushd %~1.extracted
unrar e %1
popd
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.