2

The -i and -x parameters of the 7-zip CLI interpet ! in a special way. Or at least it looks that way from their documentation. That documentation includes the following:


Syntax

-i[<recurse_type>]<file_ref>

<recurse_type> ::= r[- | 0]
<file_ref> ::= @{listfile} | !{wildcard}

Parameters

    <file_ref>

Specifies filenames and wildcards, or a list file, for files to be processed.

    <file_ref> ::= @{listfile} | !{wildcard}

Examples

7z a -tzip src.zip *.txt -ir!DIR1\*.cpp

adds to src.zip archive all *.txt files from current directory and all *.cpp files from directory DIR1 and from all it's subdirectories.


I haven't, however, found an explicit statement about how ! is meant to be used. It seems from the reference to !{wildcard} that ! might indicate that <file_ref> contains wildcards. I'm skeptical about that, however, because such an indicator seems unnecessary.

How, exactly, is ! meant to be used with 7-zip CLI parameters?

1 Answer 1

4

7z Command Line Syntax essentially preserves some kind of standard syntax key of Backus-Naur form:

Notation                           Description
Text without brackets or braces    Items you must type as shown
<Text inside angle brackets>       Placeholder for which you must supply a value
[Text inside square brackets]      Optional items
{Text inside braces}               Set of required items; choose one
Vertical bar (|)                   Separator for mutually exclusive items; choose one
Ellipsis (…)                       Items that can be repeated

As neither @ nor ! is enclosed in any brackets or braces, you need to use them literally:

  • @{listfile}: Specifies name of list file. See List file description
  • !{wildcard}: Specifies wildcard or filename

Example:

  • -i@c:\temp\abc.txt means include all files matching criteria listed in the c:\temp\abc.txt file
  • -i!c:\temp\abc.txt means include the file c:\temp\abc.txt itself.
1
  • Thanks for the references to the apparent syntax key. That makes interpretation of the 7-zip documentation much clearer.
    – alx9r
    Dec 27, 2015 at 2:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .