# Solved: Batch File array



## jat421 (Jun 14, 2008)

Hi,

I have about 50 folder with even odd subfolder and there are files in the subfolders. What I want to accomplish is that to give bunch of directory paths to the batch file and the batch file goes through each directory and zip the files inside each dir. I have already figured out the zipping part but I need help with storing lets say about 20 path in a array. Something like below:

set 1 = c:\temp
set 2 = c:\temp\temp1\temp2
set 3 = c:\temp\temp1
set 4 = c:\temp\temp2\temp3\temp4
set 5 = c:\temp

And then I want to loop through each number and do the zip process.

Thanks for any help


----------



## jat421 (Jun 14, 2008)

This is what I have so far the only issue I seem to be having is that I want to save the zip file inside the subfolder where all the files are. Right now it's zipping them to the c:\temp folder. Thanks for any help


```
set ZipProg="C:\Program Files\WinZip\WZZIP.exe"
for /f "tokens=* delims=" %%G in (test.txt) Do (%ZipProg% -u -EX "%%G.zip" %%G)
```


----------



## Squashman (Apr 4, 2003)

Maybe this will give you some insight


```
@Echo Off & SetLocal EnableExtensions EnableDelayedExpansion
FOR /F %%I in (test.txt) DO (
	echo Working Directory is: !CD!
	echo Zipping Directory is: %%I
)
```
Output

```
Working Directory is: E:\batch files\FileZipper
Zipping Directory is: c:\temp
Working Directory is: E:\batch files\FileZipper
Zipping Directory is: c:\temp\temp1\temp2
Working Directory is: E:\batch files\FileZipper
Zipping Directory is: c:\temp\temp1
Working Directory is: E:\batch files\FileZipper
Zipping Directory is: c:\temp\temp2\temp3\temp4
Working Directory is: E:\batch files\FileZipper
Zipping Directory is: c:\temp
```
But if you add a line of code.

```
@Echo Off & SetLocal EnableExtensions EnableDelayedExpansion
FOR /F %%I in (test.txt) DO (
	pushd %%I
	echo Working Directory is: !CD!
	echo Zipping Directory is: %%I
)
```
Output

```
Working Directory is: C:\temp
Zipping Directory is: c:\temp
Working Directory is: C:\temp\temp1\temp2
Zipping Directory is: c:\temp\temp1\temp2
Working Directory is: C:\temp\temp1
Zipping Directory is: c:\temp\temp1
Working Directory is: C:\temp\temp2\temp3\temp4
Zipping Directory is: c:\temp\temp2\temp3\temp4
Working Directory is: C:\temp
Zipping Directory is: c:\temp
```


----------



## jat421 (Jun 14, 2008)

Works like a charm Thanks Squashman!


----------



## Squashman (Apr 4, 2003)

I appreciate the gratitude but it would be great if you contributed some of your free time to helping others on the forums once in a while.


----------



## jat421 (Jun 14, 2008)

Will definitely do. Thanks Squashman


----------

