none
Compress/zip files from the command line in Windows 7?

    Question

  • In Windows 7 is there a native way to compress or zip files from the command line?  I'd like to do it without installing any third-party utilities such as 7Zip.
    Tuesday, March 08, 2011 9:30 PM

Answers

  • Hi,

     

    You can use Compact command. For more information, please refer to the following article.

     

    http://technet.microsoft.com/en-us/library/bb490884.aspx

     

    Best Regards,

    Niki


    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, March 10, 2011 9:52 AM
    Moderator
  • check this:

    http://superuser.com/questions/201371/create-zip-folder-from-the-command-line-windows


    "A programmer is just a tool which converts caffeine into code"

    Want to install RSAT on Windows 7 Sp1? Check my HowTo: http://www.msfn.org/board/index.php?showtopic=150221
    • Marked as answer by Vivian Xing Tuesday, March 15, 2011 3:13 AM
    Tuesday, March 08, 2011 9:51 PM

All replies

  • check this:

    http://superuser.com/questions/201371/create-zip-folder-from-the-command-line-windows


    "A programmer is just a tool which converts caffeine into code"

    Want to install RSAT on Windows 7 Sp1? Check my HowTo: http://www.msfn.org/board/index.php?showtopic=150221
    • Marked as answer by Vivian Xing Tuesday, March 15, 2011 3:13 AM
    Tuesday, March 08, 2011 9:51 PM
  • Hi,

     

    You can use Compact command. For more information, please refer to the following article.

     

    http://technet.microsoft.com/en-us/library/bb490884.aspx

     

    Best Regards,

    Niki


    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, March 10, 2011 9:52 AM
    Moderator
  • Thanks for the reminder about the native Windows COMPACT.EXE.  With the files I have I see it compresses to a ratio of about 2.3:1; with 7ZIP creating a .ZIP file the ratio is about 6:1.  So there's definitely a difference but it's something we may be able to live with.  Thank you.

    Thursday, March 10, 2011 3:43 PM
  • Hi,

     

    You can use Compact command. For more information, please refer to the following article.

     

    http://technet.microsoft.com/en-us/library/bb490884.aspx

     

    Best Regards,

    Niki


    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    This response is 100% wrong.  It accomplishes no part of the request.
    Thursday, October 03, 2013 8:02 PM
  • I fully agree that Compact is not the answer. There are additional concerns with the Compact command. It enables disk compression which is a total no-no. Very bad! It makes your computer very slow and is quite difficult to undo. The only time anyone should use this command is when they're removing disk compression because someone turned it on to save space.  Turning this off has to be done by booting into the recovery console, if my memory serves me correctly, and it's a real nuisance.  So definitely no to the Compact command.

    If you wanted to compress files before sending them to another drive, or over a network, or by email, then Compact wouldn't actually help at all because the files have to get uncompressed whenever they're accessed, especially before sending them anywhere.  When I say accessed, I mean that just looking at a file triggers the OS to decompress it in the background and present you with an uncompressed version of it then letting you change it and recompressing it again for storage every single time you access the file, which is why your machine gets slower.  If you have folders or files that have blue text instead of black, then you've probably already made this mistake.

    I would also like to know if there is a built-in command for zipping files/directories, or, if there isn't such a thing built into Windows, then I would like to know if this is feature is accessible through Visual Studio, which would be just as good as having a command-line program for those of us that do a bit of programming.

    If anyone knows if MS provides such a feature, either by command-line or through an API, then I'd love to hear about it.  Good luck to those of you that have disk compression turn on.

    Monday, April 28, 2014 5:06 PM
  • @FollowTheLion: If you want to be able to create zip archives from .NET code, take a look at the System.IO.Compression namespace in the System.IO.Compression(.FileSystem) assemblies of .NET Framework 4/4.5, everything you need to manage zip files from code.

    Jaap Mosselman

    Wednesday, September 24, 2014 11:42 AM
  • I know this is old but I was looking for a way to do this for a bat script and was able to without any third-party installs.

    Just use the built is zip command.

    Example: zip - test.txt >> test.zip

    This will create test.zip containing test.txt.  You can specify the full path if needed.

    Friday, December 12, 2014 6:34 PM
  • Interesting. This works by creating a compressed zip file. Does anyone see any issues with using this to create the ZIP files in a batch job?

    The actual command that worked is:

    copy "E:\foldername1\foldername2\DirectorytoCompress" "E:\foldername1\foldername2\DirectorytoCompressNewName.zip"

    Could have kept the original name as well .zip.

    Anyway, worked for me in a batch script. I wasn't too concerned about the level of compression, if any.

    However, the zip file rubbish. So wouldn't even advise going this direction


    • Edited by Fazboy Wednesday, February 11, 2015 4:14 PM
    Wednesday, February 11, 2015 3:56 PM