I need to write a batch file to unzip files to their current folder from a given root folder.

Folder 0
    |----- Folder 1
    |          |----- File1.zip
    |          |----- File2.zip
    |          |----- File3.zip
    |----- Folder 2
    |          |----- File4.zip
    |----- Folder 3
               |----- File5.zip
               |----- FileN.zip

So, I wish that my batch file is launched like so:

ocd.bat /d="Folder 0"

Then, make it iterate from within the batch file through all of the subfolders to unzip the files exactly where the .zip files are located.

So here's my question:

Does the Windows (from XP at least) have a command line for its embedded zip tool? Otherwise, shall I stick to another third-party util?

  • 1
    I believe .NET has Zipping assemblies natively, so if powershell is an option for you that might be useful. msdn.microsoft.com/en-us/library/3z72378a%28v=VS.100%29.aspx – jishi Jun 3 '10 at 16:14
  • @jishi: Won't help you much in creating a ZIP file, though. That's just for compressing a stream; you would still have to fit some metadata in there somewhere. – Joey Jun 6 '10 at 23:45

Yeah, it's called COMPRESS.EXE

  • Shall I consider using it and assume that the users will for usre have it, or using a third-party would be preferable? – Will Marcouiller Jun 3 '10 at 16:20
  • isn't that on the windows isntallation cd for manually compress / decompress those filename.dl_ files? – jishi Jun 3 '10 at 16:25
  • It's built into Windows XP, which is what you asked for. Try it, right now, from your command line, and see what it says. – mfinni Jun 3 '10 at 16:26
  • It says "File not found blah blah blah...". Probably the PATH environment variable not set properly, I guess. Though this brings us to my alternative solution: third-party tool, which was also part of the question. =) – Will Marcouiller Jun 3 '10 at 16:37
  • Balls - I thought it was built into Windows XP, but it's part of the Resource Pack. But, if you're considering bundling a 3rd-party tool, why don't you just bundle compress.exe ? – mfinni Jun 3 '10 at 16:46

My best guess goes with 7 Zip and its command line tool 7za.exe which I downloaded at: nload 7-Zip for Windows:.

Should you need the command line parameters or some examples of using 7za.exe, please see this link: 7-Zip Command-Line Examples

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.