Command to open zip file in windows

Command to open zip file in windows

a command line
multi function tool.

free external tools,
zero install effort,
usb stick compliant:

How to get zip and unzip on the windows command line for quick creation and extraction of zip compressed files.

Download the free Windows executables: (for Linux, see below)

    to extract zip files on the command line, download unzip.exe here.

this file is a copy of the original Info-ZIP unzip.exe version 5.52, provided for free under the Info-ZIP license. Alternatively, you may download it via the original Info-ZIP website.

How to use unzip? Read the examples below.

to create zip files on the command line, download zip.exe here.

this file is a copy of the original Info-ZIP zip.exe version 2.32, provided for free under the Info-ZIP license. Alternatively, you may download it via the original Info-ZIP website.

How to use zip? Read the examples below.

  • to create or extract zip files more flexible, like
    • include or exclude sub folders or filenames
    • zip only files changed today, or in the last 3 days
    • with full UTF-8 unicode filename support

    download Swiss File Knife here. Then type sfk zip or sfk unzip and read the examples.

    this tool is created and maintained only by this website, www.stahlworks.com, and not associated with Info-ZIP. Swiss File Knife Base is Free Open Source, BSD licensed. (more)

    to extract .tar.gz and .tar.bz2 files under windows, download:

    gzip.exe 1.3.12 a copy from http://gnuwin32.sourceforge.net/
    bzip2.exe 1.0.5 a copy from http://www.bzip.org/
    tar.exe a copy from http://sourceforge.net/projects/unxutils/

    All binaries can be used instantly, requiring no further DLL’s.
    Some command examples:

    gzip -d foo.tar.gz uncompresses foo.tar.gz, replacing it by foo.tar
    bzip2 -d foo.tar.bz2 uncompresses foo.tar.bz2, replacing it by foo.tar
    tar tvf foo.tar lists the contents of foo.tar
    tar xvf foo.tar extracts the contents of foo.tar
    • Zip and Unzip for newer (lib6 based) distributions: unzip 5.51, zip 2.3
    • Zip and Unzip for older (lib5 based) distributions: unzip 5.50, zip 2.3

    These files are copies from the Info-Zip download locations listed above,
    provided under the Info-ZIP license.

  • The gzip, bzip2 and tar commands should be available on your linux already.
  • zzfind and sfk for newer (lib6 based) distributions: zzfind, sfk
  • zzfind and sfk for newer (lib5 based) distributions: zzfind, sfk

    These files are provided for free under the BSD license.

    Further zip tools of possible interest:

    Although not discussed here, it should be mentioned that the original Info-ZIP homepage provides further tools, e.g. for the creation of self-extracting zips, gzip and zipsplit, and of course zip/unzip binaries for many other operating systems.

    Example for searching through zip file contents:

    searches all .java files within eclipse.zip for lines with the words «public» AND «class».
    Note that zzfind can also search files in a zip within a zip (nested zips).

    How to list nested zip file contents (zips or jars within zips):

    For example, if you download the Eclipse SDK and type you get a listing of less than 2000 files, listing also .jar file names. But how can you also list what is inside the .jar files, without the need to extract everything first?

    Download Swiss File Knife Base, then type: This will produce a listing of all files, no matter how deeply nested — in total nearly 70000 lines that can be very long, for example:

    eclipse-SDK-3.3.2-win32.zip\\eclipse\plugins
    \org.eclipse.ant.core_3.1.200.v20070522.jar\\lib
    \antsupportlib.jar\\org\eclipse\ant
    \internal\core\ant\EclipseAntMain.class

    The above is the text of a single line (filename), split into 4 lines here for better reading.

    As you can see, there is a .class file in a .jar within another .jar within the .zip.

    Limitations: SFK may not be able to process very large zip files, zip files with an unusual compression method, or 64 bit zip files. Type sfk help xe to list all limitations.

    How to list the contents of all .zip files in all subdirectories:

    In the example above, we listed the content of a single zip file. But sfk can also list the contents of all .zip, .jar, .ear, .war and .aar files in a directory tree. type: and get the most comprehensive listing of all files, all .zip (.jar etc) file contents
    and even zip contents embedded within other zips.

    Flexible file selection for zipping, using sfk:

    If you don’t want to zip all files of a directory tree, but for example

    • files that changed today, or since a date
    • files with a specific file extension
    • all files except those in subdirectories \save\ and \tmp\
    • files that are different compared to another directory

    then you have to prepare a file list with the swiss file knife, and send this to the zip tool through zip’s option -@ (read file list from standard input).

    example: zipping files changed today

    four files were changed today, so only those are packed into update.zip.

    example: including/excluding by filename

    only files with extension .txt are collected from the docs directory, excluding files
    • which are located in any subdirectory named «tmp»
    • having «-save.» in their name

    the example uses sfk for windows syntax. linux users have to type «:» instead of «!».

    example: comparing directories

    we have two directory trees, «docs» and «docs-old». the latter one is a copy of docs, made some days ago. meanwhile, there have been changes in «docs». but what changes?

    this command only lists what has changed so far:
    • some files have been added.
    • some files have differences, i.e. have been edited meanwhile.

    so let’s collect all these differences into a .zip. notice that zip would be irritated by the [add] and [dif] prefixes in each line, therefore we have to add sfk option -pure:

    now let’s send this to zip:

    NTFS and ZIP — execution prevention problem:

    i experienced one small problem when using the command-line (un)zip together with NTFS file systems; in short terms, after unzipping «.msi» files, I was unable to install software from these files. windows complained that access to the files was not possible or denied (due to some «execution prevention» mechanism introducted with XP SP2). this was probably because i zipped those files from a FAT partition (maybe even with an older zip tool) and then unzipped them on NTFS. the solution was to copy the files to a partition with FAT(32) file system, e.g. an USB stick, and then to run the installer from there.

    NTFS and ZIP — filetime jumps:

    another issue concerns filetimes, especially when zipping/unzipping accross FAT and NTFS partitions. in short terms, if you zip files from a FAT partition, then unpack this .zip on an NTFS partition, you always have to expect that the filetimes may be changed globally by a few hours. This is not at all a bug in the zip tool — it’s due to the way that NTFS manages filetimes internally. in case you’re irritated by this, try the following: 1) remember the filetimes in some directory on an NTFS partition. 2) change the date of your system from summer to winter time, or vice versa 3) have a look again at the filetimes and be shocked: all file times have jumped by one hour! so this is not a zip-specific problem, but it may show up when you compare times listed in a .zip file with those of the files actually created.

    7-Zip command to create and extract a password-protected ZIP file on Windows?

    On Mac/Linux to zip/unzip password protected zip files, I use: Zip:

    What are the equivalent command on Windows on the command line (assuming that 7zip has been installed)?

    I have been doing research and found that it is not possible to password encrypt using the Java zip4j library. Also Windows does not have a zip command prompt like Mac/Linux

    4 Answers 4

    Then provide the SECRET password

    Note: If the password contains spaces or special characters, then enclose it with single quotes

    General Syntax:

    Check your 7-Zip dir. Depending on the release you have, 7z may be replaced with 7za in the syntax.

    Parameters:

    • -p encrypt and prompt for PW.
    • -pPUT_PASSWORD_HERE (this replaces -p) if you want to preset the PW with no prompt.
    • -mhe=on to hide file structure, otherwise file structure and names will be visible by default.

    Eg. This will prompt for a PW and hide file structures:

    Eg. No prompt, visible file structure:

    And so on. If you leave target blank, 7z will assume * in current directory and it will recurs directories by default.

    To fully script-automate:

    Create:

    Unzip:

    (Depending, you might need to: Set Path=C:\Program Files\7-Zip;%Path% )

    I’m maybe a little bit late but I’m currently trying to develop a program which can brute force a password protected zip archive. First I tried all commands I found in the internet to extract it through cmd. But it never worked. Every time I tried it, the cmd output said, that the key was wrong but it was right. I think they just disenabled this function in a current version.

    What I’ve done to Solve the problem was to download an older 7zip version(4.?) and to use this for extracting through cmd.

    This is the command: «C:/Program Files (86)/old7-zip/7z.exe» x -pKey «C:/YOURE_ZIP_PATH»

    The first value(«C:/Program Files (86)/old7-zip/7z.exe») has to be the path where you have installed the old 7zip to. The x is for extract and the -p For you’re password. Make sure you put your password without any spaces behind the -p! The last value is your zip archive to extract. The destination where the zip is extracted to will be the current path of cmd. You can change it with: cd YOURE_PATH

    Now I let execute this command through java with my password trys. Then I check the error output stream of cmd and if it is null-> then the password is right!

    How can you zip or unzip from the script using ONLY Windows’ built-in capabilities?

    In Windows you can zip some files by

    right click → Send toCompressed (zipped) folder

    And unzip by double clicking on the .zip file and extract the files.

    Is there a way to apply those abilities from a script (.bat file) without the need to install any third-party software?

    16 Answers 16

    Back in 2013, that was not possible. Microsoft didn’t provide any executable for this.

    From Windows 8 on, .NET Framework 4.5 is installed by default, with System.IO.Compression.ZipArchive and PowerShell available, one can write scripts to achieve this, see https://stackoverflow.com/a/26843122/71312

    To expand upon Steven Penny’s PowerShell solution, you can incorporate it into a batch file by calling powershell.exe like this:

    As Ivan Shilo said, this won’t work with PowerShell 2, it requires PowerShell 3 or greater and .NET Framework 4.

    If you have Java installed, you can compress to a ZIP archive using the jar command:

    c = Creates a new archive file.

    M = Specifies that a manifest file should not be added to the archive.

    f = Indicates target file name.

    PowerShell 5.0

    Create result.zip from the entire Test folder:

    Extract the content of result.zip in the specified Test folder:

    It isn’t exactly a ZIP, but the only way to compress a file using Windows tools is:

    Advanced example (from ss64.com):

    Using 7-Zip:

    Zip: you have a folder foo , and want to zip it to myzip.zip

    Unzip: you want to unzip it ( myzip.zip ) to current directory ( ./ )

    100 machines in production which don’t have 7zip on them. To install that I would have to get the DevOps install it on all those machines and on all new machines that will be added to the clusters. I would rather avoid it. – Roee Gavirel May 9 ’16 at 5:27

    I’ve been looking to answer this exact question and from my research, DiryBoy’s response seems to be accurate.

    I found the compact.exe program compresses files but not to create a highly compressed file (or set of files). It is similar to the option you get when right clicking on a drive letter or partition in Windows. You get the option to do cleanup (remove temp files, etc) as well as compress files. The compressed files are still accessible but are just compressed to create space on a drive that is low on space.

    I also found compress.exe which I did happen to have on my computer. It isn’t natively on most windows machines and is part of the 2003 resource kit. It does make a zipped file of sorts but it is really more similar to files from a windows setup disk (has the underscore as the last character of the file extension or name). And the extract.exe command extracts those files.

    However, the mantra is, if it can be done natively via the GUI then there is likely a way to do it via batch, .vbs, or some other type of script within the command line. Since windows has had the ‘send to’ option to create a zip file, I knew there had to be a way to do it via command line and I found some options.

    Here is a great link that shows how to zip a file using windows native commands.

    I tested it with a directory containing multiple nested files and folders and it worked perfectly. Just follow the format of the command line.

    There is also a way to unzip the files via command line which I found as well. One way, just brings open an explorer window showing what the content of the zipped file is. Some of these also use Java which isn’t necessarily native to windows but is so common that it nearly seems so.

    Читайте также:  Как сделать все значки крупными windows 10
  • Оцените статью