7zip: How to exclude files (not file types) using an exclude list file

7-zipcommand lineexclude

I know you can create a text file containing a list of files and then tell 7zip to reference this file so that it can exclude them from the archive, but I cannot find the syntax for that. Can someone help?

Best Answer

After a few hours of searching, I finally figured it out. Here's the switch syntax:

7z a -xr@exclude.txt backup.7z c:\whatever\*

Notice -xr instead of -x. The r indicates recursive so it can match excluded files in deep folder hierarchies. Also, the format of the text file can be at least ANSI or UTF-8.

As for the file containing the files, as OldWolf said, it's a list separated by carriage returns like this:

Telerik.Reporting.dll
Telerik.Reporting.Service.dll
Telerik.ReportViewer.WebForms.dll
Telerik.Web.Design.dll
Telerik.Web.UI.dll
*.txt

Works like a charm.

Related Question