0

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?

Will Marcouiller
  • 256
  • 2
  • 5
  • 16
  • 1
    I believe .NET has Zipping assemblies natively, so if powershell is an option for you that might be useful. http://msdn.microsoft.com/en-us/library/3z72378a%28v=VS.100%29.aspx – jishi Jun 03 '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 06 '10 at 23:45

2 Answers2

1

Yeah, it's called COMPRESS.EXE

mfinni
  • 36,144
  • 4
  • 53
  • 86
  • 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 03 '10 at 16:20
  • isn't that on the windows isntallation cd for manually compress / decompress those filename.dl_ files? – jishi Jun 03 '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 03 '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 03 '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 03 '10 at 16:46
  • I've performed a file-search and I can't find it anywhere. =( – Will Marcouiller Jun 03 '10 at 17:02
  • I know - if you don't have the Resource Kit, it's not on your machine. Download and install the Resource Kit, find the EXE, and bundle that. It's cheaper than buying a 3rd-party tool. – mfinni Jun 03 '10 at 17:24
  • Will this Resource Kit only works on Windows XP machines and later, or could it also work on older systems like Windows 2000? – Will Marcouiller Jun 04 '10 at 02:53
  • I have no idea; I'm not going to read the documentation for you at this point. I know that this forum is to have good questions and answers, and "LMGTFY" isn't a great answer, but really - you've been pointed in a certain direction and aren't willing to walk on your own. Why has your compatibility requirement changed from XP+ to 2000+, since yesterday? You haven't even said what this is for and who the users will be. Is this for a company you work for, or is this for a product you're selling? Are the users/customers tech-savvy, or not? – mfinni Jun 04 '10 at 13:00
0

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

Will Marcouiller
  • 256
  • 2
  • 5
  • 16