0

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.

0

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

| improve this answer | |
1

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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