Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .