When extracting files from a .7z archive, there may be instances where you want to exclude certain files from being extracted. This could be due to a number of reasons, such as not having enough storage space, not needing the file, or the file being corrupt or unnecessary. In this guide, we will show you how to exclude files during .7z extraction, with easy-to-follow steps for both the graphical user interface (GUI) and command line interface (CLI) of 7-Zip.
Excluding Files using the GUI
To exclude files using the 7-Zip GUI, follow these steps:
- Open the .7z archive you want to extract using 7-Zip.
- Navigate to the directory containing the files you want to exclude.
- Select the files you want to exclude by clicking on them. You can also select multiple files by holding down the Ctrl key while clicking on the files.
- Right-click on the selected files and choose
Excludefrom the context menu. - Click on the
Extractbutton to start the extraction process. The excluded files will not be extracted.
Note: The Exclude option is only available when you have selected one or more files. If you have not selected any files, the Exclude option will be grayed out.
Excluding Files using the CLI
To exclude files using the 7-Zip CLI, follow these steps:
- Open the Command Prompt or PowerShell and navigate to the directory containing the .7z archive.
- Type the following command to extract the files from the archive:
7z e archive.7z -ooutput_dir -xr!exclude_pattern - Replace
archive.7zwith the name of your .7z archive,output_dirwith the name of the directory where you want to extract the files, andexclude_patternwith the name of the file or directory you want to exclude. - Press Enter to run the command. The files will be extracted to the specified directory, excluding the specified file or directory.
For example, if you have a .7z archive called my_archive.7z and you want to extract the files to a directory called my_directory, excluding a file called excluded_file.txt, the command would look like this:
7z e my_archive.7z -omy_directory -xr!excluded_file.txt
Note: The -xr option is used to exclude files or directories that match the specified pattern. The ! symbol is used to specify the exclude pattern. You can use wildcards in the exclude pattern to exclude multiple files or directories. For example, to exclude all files with the .txt extension, you would use the following command:
7z e my_archive.7z -omy_directory -xr!*.txt
This would extract all files from the archive, except for those with the .txt extension.
Excluding files during .7z extraction is a useful feature that can help you manage your files and save storage space. By following the steps outlined in this guide, you can easily exclude files using either the 7-Zip GUI or CLI. Whether you are a beginner or an experienced user, these steps will help you exclude files quickly and easily.
References
| Title | URL |
|---|---|
| 7-Zip - Command Line Version | https://www.7-zip.org/download.html |
| 7-Zip - Using the command line | https://sevenzip.osdn.jp/chm/cmdline/switches/extract.htm |