Windows command line 7zip


















Before we proceed with our examples, check out other guides, and reviews on our website. Because they are only single letters, they are quite easy to memorize. Aside from looking for the details about 7-Zip download for PC or for Linux , it is important to have idea about archive error. The function letter a command is used to put data in the archives.

Using the command will look like this on the terminal line:. The function letter d command is used for removing a particular file or files from an archive. The function letter e command is useful when there is no substantial archive.

Meanwhile, the function letter x command works the same way with e. The difference is it preserves the full paths. This is useful if you have an elaborate or important directory structure. Also, this is useful for backups. Using the command on the terminal looks like this:. This function letter lowercase L command is used to list the archive contents.

However, you may not need to use this command it often. This function letter t command is used to test the integrity of archives. This function letter u command is used to replace old files in your archive with newer files. This command prevents needing to decompress and recompress the entire archive. Arguments You have to specify the destination archive, and the source files in that order. The command puts those 2 files in an archive.

Command E. To continue, "e" is next most important command second to "a". The "e" stands for extract, and it means to unzip or expand an archive. We must specify the source archive. Info The "e" command extracts everything to a specified directory. Another command "x" can preserve directory structures in archives. Prompts 7-Zip will always prompt you if there is a file it needs to overwrite to extract the new file.

Use -y to skip the prompt. Command L. The lowercase L is used to list the contents of archives. You probably will not need to use it often. I thought I would test it and show an example. Next This shows the listing of a solid archive. The originals are bytes and bytes. They compress down to bytes. Command D. We use the "d" command in 7-Zip command lines. This stands for delete. It allows you to remove a certain file or set of files from inside an archive. Note You will need this if you use huge archives and need to save time.

This is from the manual. Tip You can also remove a single file from an archive with "d. Command T. Here we use the "t" command in the 7z program. This command allows you to test the integrity of archives.

It stands for "test" and is much less useful than the "-t" switch. Warning Do not confuse the two. This one is used for diagnostics. We usually want the hyphen "-t. Command U. This stands for update. This command replaces old files in your archive with newer files. This prevents needing to decompress and recompress the entire archive. Warning The "u" command doesn't work with solid archives. A solid archive is one where all the files are compressed together.

So You cannot update specific files in solid archives with the "u" command. Solid archives are limited. Switch m. We can change the optimization settings in 7-Zip on the command line.

This is the most important and useful option you can use. Tip It specifies the method of compression. Here we show a bunch of options, and also some examples. Switch -mfb Specifies number of fast bytes. Sometimes helps with "sparse" files. Don't bother. Switch -mpass Number of passes for deflate compression. Don't bother with this. Automatically set with levels. Switch -md This specifies dictionary size. It is automatically set, so don't bother.

Specify "on" or "off. Command X. This command is like "e" except it preserves the full paths. If you have an elaborate or important directory structure, use this option. This would be most useful for backups. Switch T type. Here we show how to specify the archive type. Note that you can specify any file name you want for any type. But some extensions are recommended—they are standard.

Type switch examples. The 7-Zip manual shows the -tiso and -tudf switches. These are not the most common. Almost all of the examples in this document use -t switches. Example commands. Here I show the example compression commands from the 7-Zip manual. You can specify a password on the command line. The syntax is a bit funky. Opening password-protected archives. This next console output shows what happens when you try to open the password-protected archive.

Header encryption: Add -mhe to encrypt headers. The password command will automatically deal with encrypted headers. More switches. Here we take a closer look at more switches that are of limited use.

They are useful to know, however, if you ever need to use them. Usually you can do better just by using the defaults that are slightly adjusted for your requirement. Switch -ssc: Specify case-sensitive mode. The default is -ssc- on Windows insensitive. The default is -scc on Linux sensitive. Switch -ssw: Compress locked files. You can try this if you have problems opening files. Switch -w: Set working directory.

You can use this when you want to specify temp folders. We can use case-insensitive file names in the 7-Zip command line. For those of you who use both Linux and Windows, the case-sensitive option is useful. I will show my own example here with some explanation. Switch v. You can use the "v" switch on the command line. In data compression, a volume is a segment of a data set that is a certain number of bytes long.

The volume switch specifies the exact size in bytes, kilobytes or megabytes. Also: You can specify sequential volumes with the "v" switch on the 7za. Switch ao. The "ao" switch allows you to specify whether you want to overwrite old files. Be careful—you cannot restore an overwritten file normally. It takes another argument. Back up your data by copying the files in your file manager first.

Switch -aoa: This switch overwrites all destination files. Use it when the new versions are preferred. Switch -aos: Skip over existing files without overwriting. Use this for files where the earliest version is most important. Switch -aou: Avoid name collisions. New files extracted will have a number appending to their names.

You will have to deal with them later. Switch -aot: Rename existing files. This will not rename the new files, just the old ones already there. Multiple files. This section addresses adding multiple files to an archive.

Specify the name of the destination archive file and the source files afterwards. Tip: Please read more in the section covering the "a" command, found in the previous part of this page. How do I add many files with a specific extension? You can use the wildcard anywhere. How can I add many files from an entire subdirectory?

Specify just the directory name. You do not need to use a wildcard. The 7-Zip manual helpfully shows this example. It specifies an entire directory called "subdir".

This section answers questions about choosing formats. First, to use GZip compression, please specify the "-tgzip" option for the type switch. This makes a great way to compress files on your web server for HTTP compression. How do I use BZip2? You can use BZip2 by specifying the "-tbzip2" switch. This can be combined with any compression level in the above charts. The different modes in 7-Zip automatically use many different settings. How do I use 7z format?

By specifying the "-t7z" switch for type. Or you can simply omit the type switch and that will default to 7z. This format offers the greatest compression ratios, but it does not work in all places.

You can stop 7-Zip from displaying prompts. Please use the -y switch. This will assume a yes answer to all prompts. Use this only when you are confident that you are not going to lose any data.

There are many more possibilities and usages of the 7-Zip program on the command line in both Windows and Linux. This section answers some questions I had when doing this research, and also some questions that you may have. Why can't I update my archive? It is probably a solid archive. Change the archive not to be solid if you want to update it. Search this page for "solid".

Can I specify the output directory? Yes—please use the "e" command and combine it with the -o switch. The syntax with -o is a bit funny so I will show the example from the 7-Zip help file. Here's how it works. How can I see what's inside an archive? Use the "l" command as shown above. You might want to use "l" in a utility that you run from a command line to make sure your batch archiving properly works.

How can I exclude certain files? Near the start we saw how to add files based on filters, but sometimes you want to manually exclude certain files.

Use the -x switch, followed immediately with an exclamation mark and then the filename. So: If you want to exclude "file1.



0コメント

  • 1000 / 1000