Multiple directory file operations

batchcommand linewindowswindows-explorer

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.

Best Answer

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