# -u (Update options) switch

Specifies how to update files in archive and (or) how to create new archives.

#### Syntax

    -u[-]<action_set>[!{new_archive_name}]

      <action_set> ::= <state_action>...

        <state_action> ::= <state><action>

          <state> ::= p | q | r | x | y | z | w

          <action> ::= 0 | 1 | 2 | 3

#### Parameters

dash (-)

  Disables any updates in base archive.

  Term base archive means archive assigned by "base_archive_name" string in command line. See Command line syntax for more details.

{new_archive_name}

  Specifies path of the new archive, which must be created. All options in this switch will refer to this new archive.

  If not assigned, then all options in this switch will refer to base archive of command.

<state>

  Specifies state for particular processed file.

      <state> ::= p | q | r | x | y | z | w

  For each unique filename there are 6 variants of state:

  <state> | State condition | File on Disk | File in Archive
  --- | --- | --- | ---
  p | File exists in archive, but is not matched with wildcard. |  | Exists, but is not matched
  q | File exists in archive, but doesn't exist on disk. | Doesn't exist | Exists
  r | File doesn't exist in archive, but exists on disk. | Exists | Doesn't exist
  x | File in archive is newer than the file on disk. | Older | Newer
  y | File in archive is older than the file on disk. | Newer | Older
  z | File in archive is same as the file on disk | Same | Same
  w | Can not be detected what file is newer (times are the same, sizes are different) | ? | ?

<action>

  Specifies action for appropriate <state>.

      <action> ::= 0 | 1 | 2 | 3

  For each state you can specify one of the three variants of actions:

  <action> | Description
  --- | ---
  0 | Ignore file (don't create item in new archive for this file)
  1 | Copy file (copy from old archive to new)
  2 | Compress (compress file from disk to new archive)
  3 | Create Anti-item (item that will delete file or directory during extracting). This feature is supported only in 7z format.

#### Remarks

Any update command (such as a (Add), d (Delete), u (Update)) can be assigned in these terms.

The following table shows action sets for update commands.

command \ <state> | p | q | r | x | y | z | w
--- | --- | --- | --- | --- | --- | --- | ---
d (Delete) | 1 | 0 | 0 | 0 | 0 | 0 | 0
a (Add) | 1 | 1 | 2 | 2 | 2 | 2 | 2
u (Update) | 1 | 1 | 2 | 1 | 2 | 1 | 2
Synchronize | 1 | 0 | 2 | 1 | 2 | 1 | 2

If you don't specify !{new_archive_name} option, then all options will refer to main archive (archive assigned in command line after command). If you specify !{new_archive_name} option, then 7-Zip also will create a new archive with specified name and all options will refer to that new archive.

Multiple update switches are supported. 7-Zip can create any number of new archives during one operation.

By default, action set for each new archive is assigned as action set of main command. There are 3 different action sets for commands: a (Add), d (Delete), u (Update). You can overload any <state_action> pair.

#### Examples

    7z u c:\1\exist.7z -u- -up0q3x2z0!c:\1\update.7z *

creates new archive update.7z and writes to this archive all files from current directory that differs from files in exist.7z archive. exist.7z archive will not be changed.

    7z u c:\1\exist.7z -up0q3x2z0!c:\1\update.7z * -ms=off

creates new archive update.7z and writes to this archive all files from current directory that differs from files in exist.7z archive.

Note: Current version of 7-Zip cannot change archive, created with solid option switched on. To update .7z archive you must create and update archive in non-solid mode (-ms=off switch).

#### Commands that can be used with this switch

a (Add), d (Delete), u (Update),