Unzipping and re-zipping multiple files

February 28, 2011 at 07:51:35
Specs: Windows 7
I am trying to undertake the following actions:
1) Rename all Excel 2007 .xlsx files in various locations on our network to .zip files.
2) Unzip each file.
3) Execute manual search and replace operations over related .xml files.
4) Rezip each folder that relates to one .xlsx file.
5) Rename the new .zip files to .xlsx files, so that I can open the file up again in Excel.
I am thinking that I need one batch file for steps 1&2 and another batch file for steps 4&5.

Any ideas would be highly appreciated.

See More: Unzipping and re-zipping multiple files

Report •

February 28, 2011 at 12:56:08
I think you are barking up the wrong tree. You don't turn an .xlsx file into a zip file simply by renaming it.

It has to be compressed using a compression algorithm and then it is given the Zip extension.

What you need is a DOS version of PKUNZP and PKZIP that can be manipulated from the command line. via a batch file



Report •

March 1, 2011 at 03:54:40
Thanks for the reply.
My understanding is that .xlsx files are already actually .zip files. You can prove this to yourself by renaming one to a .zip file and then unzipping it.
I think that what I need to do is essentially write the following scripts:

Script 1
For each file on network
If file is a .xlsx file, Then
Unzip file
End If

Execute manual search and replace operations over the unzipped Excel folder.

Script 2
For each file on network
If file is .zip file Then
If there is a folder in the same location with the same body name as the body of the .zip file Then
Zip the folder, overwriting any pre-existing zip file (i.e., which was created via Scrip 1)
Rename the .zip file to a .xlsx file.
End If
End If

Any pointers on whether there is a better approach, or on how to get started with this approach, would be appreciated.

Many thanks.


Report •

Related Solutions

Ask Question