Specifies how to update files in an archive and (or) how to create new archives.
-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
Disables any updates in the base archive.
The term base archive means the archive assigned by "base_archive_name" on the command line. See Command line syntax for more details.
Specifies the path name of the new archive to 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 the base archive of the command.
Specifies the state of a particular file to be processed.
<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) | ? | ? |
Specifies the action for a given <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. |
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 |
Freshen | 1 | 1 | 0 | 1 | 2 | 1 | 2 |
Synchronize | 1 | 0 | 2 | 1 | 2 | 1 | 2 |
If you don't specify a !{new_archive_name} option, then all options will refer to the main archive (the archive assigned on the command line after the 7z command). If you specify !{new_archive_name} option, then 7-Zip also will create a new archive with the 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, the action set for each new archive is assigned as the action set of the main command. There are 3 different action sets for commands: a (Add), d (Delete), u (Update). You can overload any <state_action> pair.
If you change time zone (when you move your computer to another time zone or if there are clock changes for daylight saving in your zone), you can have some problems with update commands that depend from file's modification time. It's strongly recommended to use only file system that uses Coordinated Universal Time (UTC) and archive format that also uses UTC. In that case you will have no problems with time zone changes. Also it's recommended to use only UTC formats in other cases, for example, if you send files to someone in another time zone.
Also in some cases there are no problems, if both file system and archive format use local time, for example, FAT file system and ZIP format.
7z u c:\1\exist.7z -u- -up0q3x2z0!c:\1\update.7z *
creates a new archive update.7z and writes to this archive all files from current directory which differ 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 a new archive update.7z and writes to this archive all files from the current directory which differ from files in exist.7z archive.
Note: the updating of solid .7z archives can be slow, since it can require some recompression.
a (Add), d (Delete), u (Update),