How to zip a file in windows using command prompt




















I'm trying to add some commands to a pre-existing batch file. This thread is locked. You can follow the question or vote as helpful, but you cannot reply to this thread. I have the same question Report abuse. Details required :. Cancel Submit. Hi Martzx, Thank you for posting your query on Microsoft Community. Try to run the command mentioned below from command prompt and see if it helps you to zip file. Improve this answer.

Zombo Zombo 9, 20 20 gold badges silver badges bronze badges. The second option didn't work for me on 17G dump file. But [IO. ZipFile]::CreateFromDirectory did. Note to newbies like me - with tar. Free apps still can though, — EvilDr.

StevenPenny it's acceptable if you want it to work like tar works. That wasn't what I set out to do, but it will work for me now. That's a handy trick to know. It won't copy empty folders so be careful. OpenTextFile target, 2, vbtrue ' this is the header to designate a file as a zip zip. NameSpace source. Items If objItem. GetFolder objItem. Path ' if this folder is empty, then skip it as it can't compress empty folders If objFolder.

NameSpace target. Count wscript. WSkid WSkid 4 4 bronze badges. Looks promising, but I got an "Object required: 'objApp. I have the same problem. The above code doesn't work, or needs some extra stuff in the system the poster forgot to mention. It uses WScript vbs environment and several Shell objects. All were installed by default in Windows XP business? Perhaps they are longer there for Win8?

But what would be the advantage to this approach? Why not just write the PowerShell script to a fixed file and let it accept parameters? I tried all the other solutions. The most important advantage is use of powershell's native commands and no need to create the old-tech VBScript. This worked for me on an old corporate windows7 laptop in Can be run direct from CMD, no need to create. Here is a great link that shows how to zip a file using windows native commands.

Community Bot 1. LostUser LostUser 27 2 2 bronze badges. You should include the instructions in your answer. If the links go stale, your answer will be worthless Still it will work, that all you have to do is, just go to parent folder and try to zip entire folder so automatically all the items inside the folder will automatically zip, Hope it help Compress-Archive relies upon the Microsoft.

You can use the following command: zip -r nameoffile. MitulP91 MitulP91 1, 1 1 gold badge 11 11 silver badges 24 24 bronze badges. The command zip is not recognized as internal or external command. Can you suggest me in windows XP? This will not be platform independent. I think OP wants to do it using java.

The zip Package should be installed in system. ELinuxbook ELinuxbook 95 2 2 bronze badges. I assume that works on Linux, but it doesn't work on Windows. Of course, the OP didn't mention which operating system he was using. Michal Sipek Michal Sipek 6 6 silver badges 17 17 bronze badges. The Overflow Blog. Podcast Helping communities build their own LTE networks. Podcast Making Agile work for data science. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.

Linked Related



0コメント

  • 1000 / 1000