1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4
<META http-equiv="Content-Type" content="text/html; charset=Windows-1252">
5
<TITLE>-u (Update options) switch</TITLE>
6
<LINK href="style.css" rel="stylesheet" type="text/css">
11
<H1>-u (Update options) switch</H1>
13
<P>Specifies how to update files in an archive and (or) how to create new archives.</P>
18
-u<A class="parameter" href="#disable_base_archive">[-]</A><action_set><A class="parameter" href="#new_archive_name">[!{new_archive_name}]</A>
20
<action_set> ::= <state_action>...
22
<state_action> ::= <A class="parameter" href="#state"><state></A><A class="parameter" href="#state"><action></A>
24
<A class="parameter" href="#action"><state></A> ::= p | q | r | x | y | z | w
26
<A class="parameter" href="#action"><action></A> ::= 0 | 1 | 2 | 3
33
<DT><A name="disable_base_archive"></A>dash (-)</DT>
34
<DD><P>Disables any updates in the base archive.</P>
36
<P>The term <B>base archive</B> means the archive assigned by "base_archive_name"
37
on the command line. See <A href="../syntax.htm">Command line syntax</A>
40
<DT><A name="new_archive_name"></A>{new_archive_name}</DT>
41
<DD><P>Specifies the path name of the new archive to be created.
42
All options in this switch will refer to this new archive.</P>
43
<P>If not assigned, then all options in this switch will
44
refer to the base archive of the command.</P>
46
<DT><A name="state"></A><state></DT>
47
<DD><P>Specifies the state of a particular file to be processed.</P>
48
<PRE class="syntax"><state> ::= p | q | r | x | y | z | w</PRE>
49
<P>For each unique filename there are 6 variants of state:</P>
51
<TR> <TH><state></TH> <TH>State condition</TH>
52
<TH width="20%">File on Disk</TH> <TH width="20%">File in Archive</TH> </TR>
54
<TR> <TD align="center">p</TD> <TD>File exists in archive, but is not matched with wildcard.</TD>
55
<TD> </TD> <TD>Exists, but is not matched</TD> </TR>
57
<TR> <TD align="center">q</TD> <TD>File exists in archive, but doesn't exist on disk.</TD>
58
<TD>Doesn't exist</TD> <TD>Exists</TD> </TR>
60
<TR> <TD align="center">r</TD> <TD>File doesn't exist in archive, but exists on disk.</TD>
61
<TD>Exists</TD> <TD>Doesn't exist</TD> </TR>
63
<TR> <TD align="center">x</TD> <TD>File in archive is newer than the file on disk.</TD>
64
<TD>Older</TD> <TD>Newer</TD> </TR>
66
<TR> <TD align="center">y</TD> <TD>File in archive is older than the file on disk.</TD>
67
<TD>Newer</TD> <TD>Older</TD> </TR>
69
<TR> <TD align="center">z</TD> <TD>File in archive is same as the file on disk</TD>
70
<TD>Same</TD> <TD>Same</TD> </TR>
72
<TR> <TD align="center">w</TD> <TD>Can not be detected what file is newer
73
(times are the same, sizes are different)</TD>
74
<TD>?</TD> <TD>?</TD> </TR>
78
<DT><A name="action"></A><action></DT>
79
<DD><P>Specifies the action for a given <A class="parameter" href="#state"><state></A>.</P>
80
<PRE class="syntax"><action> ::= 0 | 1 | 2 | 3</PRE>
81
<P>For each state you can specify one of the three variants of actions:</P>
83
<TR> <TH><action></TH> <TH>Description</TH></TR>
84
<TR> <TD align="center">0</TD> <TD>Ignore file (don't create item in new archive for this file)</TD></TR>
85
<TR> <TD align="center">1</TD> <TD>Copy file (copy from old archive to new)</TD></TR>
86
<TR> <TD align="center">2</TD> <TD>Compress (compress file from disk to new archive)</TD></TR>
87
<TR> <TD align="center">3</TD> <TD>Create Anti-item (item that will delete file or directory during extracting). This feature is supported only in 7z format.</TD></TR>
95
<P>Any update command (such as <A href="../commands/add.htm">a (Add)</A>,
96
<A href="../commands/delete.htm">d (Delete)</A>,
97
<A href="../commands/update.htm">u (Update)</A>) can be assigned in these terms.</P>
98
<P>The following table shows action sets for update commands.</P>
101
<TR> <TH>command \ <A class="parameter" href="#state"><state></A></TH>
102
<TH>p</TH> <TH>q</TH> <TH>r</TH> <TH>x</TH> <TH>y</TH> <TH>z</TH> <TH>w</TH></TR>
103
<TR> <TH><A href="../commands/delete.htm">d (Delete)</A></TH> <TD>1</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD> <TD>0</TD></TR>
104
<TR> <TH><A href="../commands/add.htm">a (Add)</A></TH> <TD>1</TD> <TD>1</TD> <TD>2</TD> <TD>2</TD> <TD>2</TD> <TD>2</TD> <TD>2</TD></TR>
105
<TR> <TH><A href="../commands/update.htm">u (Update)</A></TH> <TD>1</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD></TR>
106
<TR> <TH><A href="../commands/update.htm">Freshen</A></TH> <TD>1</TD> <TD>1</TD> <TD>0</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD></TR>
107
<TR> <TH><A href="../commands/update.htm">Synchronize</A></TH> <TD>1</TD> <TD>0</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD> <TD>1</TD> <TD>2</TD></TR>
111
<P>If you don't specify a
112
<A class="parameter" href="#new_archive_name"><I>!{new_archive_name}</I></A> option, then
113
all options will refer to the main archive (the archive assigned on the command line after the 7z command).
114
If you specify <A class="parameter" href="#new_archive_name"><I>!{new_archive_name}</I></A>
115
option, then 7-Zip also will create a new archive with the specified name and all options
116
will refer to that new archive.</P>
118
<P>Multiple update switches are supported.
119
7-Zip can create any number of new archives during one operation.</P>
121
<P>By default, the action set for each new archive is assigned
122
as the action set of the main command. There are 3 different
123
action sets for commands: <A href="../commands/add.htm">a (Add)</A>,
124
<A href="../commands/delete.htm">d (Delete)</A>,
125
<A href="../commands/update.htm">u (Update)</A>.
126
You can overload any <state_action> pair.</P>
128
<H4>Time zone notes</H4>
129
<P>If you change time zone (when you move your computer to another time zone
130
or if there are clock changes for daylight saving in your zone), you can have some problems
131
with update commands that depend from file's modification time. It's strongly recommended to use only
132
file system that uses Coordinated Universal Time (UTC) and archive format that also uses UTC.
133
In that case you will have no problems with time zone changes.
134
Also it's recommended to use only UTC formats in other cases, for example, if you send files to
135
someone in another time zone.</P>
137
<P>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.</P>
139
<LI>UTC file systems: NTFS
140
<LI>UTC archive formats: .zip with -mtc switch, 7z, tar, gzip2, iso, wim
141
<LI>Local time file systems : FAT, FAT32
142
<LI>Local time archive formats : rar, zip, cab
147
<PRE class="example">
148
7z u c:\1\exist.7z -u- -up0q3x2z0!c:\1\update.7z *
151
<P>creates a new archive <SPAN class="filename">update.7z</SPAN> and
152
writes to this archive all files from current directory which differ from
153
files in <SPAN class="filename">exist.7z</SPAN> archive.
154
<SPAN class="filename">exist.7z</SPAN> archive will not be changed.</P>
156
<PRE class="example">
157
7z u c:\1\exist.7z -up0q3x2z0!c:\1\update.7z * -ms=off
160
<P>creates a new archive <SPAN class="filename">update.7z</SPAN> and
161
writes to this archive all files from the current directory which differ from
162
files in <SPAN class="filename">exist.7z</SPAN> archive.
164
<P>Note: The current version of 7-Zip cannot change an archive created with the solid option switched on.
165
To update a .7z archive, you must create and update the archive in non-solid
166
mode (-ms=off switch).</P>
168
<H4>Commands that can be used with this switch</H4>
171
<A href="../commands/add.htm">a (Add)</A>,
172
<A href="../commands/delete.htm">d (Delete)</A>,
173
<A href="../commands/update.htm">u (Update)</A>,