forked from svn2github/dotnetzip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCmdLine.htm
More file actions
529 lines (415 loc) · 16.6 KB
/
Copy pathCmdLine.htm
File metadata and controls
529 lines (415 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<html>
<head>
<title>ZipIt.exe and UnZip.exe</title>
<style>
p,body,a,tr,td
{ font-family: Verdana, Arial, Helvetica; font-size: 10pt }
h1,h2,h3,h4,h5,h6
{ font-family: Verdana, Arial, Helvetica; font-weight: normal; font-style: normal; }
h1 { font-size: 20pt }
h2 { font-size: 18pt; font-weight:bold; color: navy }
h3 { font-size: 16pt; font-weight:bold; color: #483d8b }
h4 { font-size: 14pt; font-weight:bold; color:#C71585; margin-bottom:2px; }
.code {font-family: Consolas, Courier; font-size: 10pt }
</style>
</head>
<!-- @SortOrder 1 -->
<body>
<h1>DotNetZip Command-Line Tools</h1>
<p>The Tools/Utilities downloads for DotNetZip include a pair of tools -
Zipit.exe and Unzip.exe - that can be used from the command line to
manipulate zip files from within batch scripts, or CMD.exe windows.
</p>
<h2>ZipIt.exe</h2>
<p>This tool can be used to create ZIP files, or update existing ZIP
files, from the command line or from a batch file. </p>
<p>Using the command line tools, you can do virtually everything you can
do by using the library directly from a custom application. You can
create self-extracting archives or archives that use ZIP64 extensions.
You can create archives that use encryption or passwords. You can
create split or spanned archives. And there are many other options. </p>
<!-- ============================================================== -->
<h3>Usage</h3>
<pre numberLines="true" outlining="true" >
ZipIt.exe <ZipFileToCreate> [arguments]
arguments:
<directory> | <file> - a directory or file to add to the archive.
<selector> - a file selection expression. Examples:
*.txt
(name = *.txt) OR (name = *.xml)
(attrs = H) OR (name != *.xml)
(ctime < 2009/02/28-10:20:00)
(size > 1g) AND (mtime < 2009-06-29)
(ctime > 2009-04-29) AND (size < 10kb)
Filenames can include full paths. You must surround a filename
that includes spaces with single quotes.
-64 - use ZIP64 extensions, for large files or large numbers of files.
-aes - use WinZip-compatible AES 256-bit encryption for entries
subsequently added to the archive. Requires a password.
-cp <codepage> - use the specified numeric codepage for entries with comments
or filenames that cannot be encoded with the default IBM437
code page.
-d <path> - use the given directory path in the archive for
succeeding items added to the archive.
-D <path> - find files in the given directory on disk.
-e<s,r,q,a> - when there is an error reading a file to be zipped, either skip
the file, retry, quit, or ask the user what to do.
-j- - do not traverse NTFS junctions
-j+ - traverse NTFS junctions (default)
-L <level> - compression level, 0..9 (Default is 6).
-p <password> - apply the specified password for all succeeding files added.
use "" to reset the password to nil.
-progress - emit progress reports (good when creating large zips)
-r- - don't recurse directories (default).
-r+ - recurse directories.
-s <entry> 'string' - insert an entry of the given name into the
archive, with the given string as its content.
-sfx [w|c] - create a self-extracting archive, either a Windows or console app.
-split <maxsize> - produce a split zip, with the specified maximum size. You can
optionally use kb or mb as a suffix to the size.
-split is not compatible with -sfx.
This is not compatible with -sfx.
-Tw+ - store Windows-format extended times (default).
-Tw- - don't store Windows-format extended times.
-Tu+ - store Unix-format extended times (default).
-Tu- - don't store Unix-format extended times (default).
-UTnow - use uniform date/time, NOW, for all entries.
-UTnewest - use uniform date/time, newest entry, for all entries.
-UToldest - use uniform date/time, oldest entry, for all entries.
-UT <datetime> - use uniform date/time, specified, for all entries.
-utf8 - use UTF-8 encoding for entries with comments or
filenames that cannot be encoded with the default IBM437
code page.
-zc <comment> - use the given comment for the archive.
</pre>
<!-- ============================================================== -->
<h3>Command Examples</h3>
<table border='1'>
<tr>
<td style='color:white;Background:Navy;'><strong>Use this Command...</strong></td>
<td style='color:white;Background:Navy;'><strong>to do this...</strong></td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe NewZip.zip -64 *.doc</td>
</tr>
<tr>
<td> </td>
<td>
create a new zip file called NewZip.zip, adding all .doc files from
the current directory
into the zip. Use ZIP64 extensions.
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe NewZip.zip -r+ *.doc</td>
</tr>
<tr>
<td> </td>
<td>
create a new zip file called NewZip.zip, adding all .doc files, in the
current directory and any child directories,
into the zip.
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe Backup.zip -d c:\MyDocuments -r+ -j- *.*</td>
</tr>
<tr>
<td> </td>
<td>
create a new zip file called Backup.zip, adding all files within the c:\MyDocuments
directory. Do not traverse NTFS Junction points (like My Videos).
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe Package.exe -sfx -d c:\files -r+ *.*</td>
</tr>
<tr>
<td> </td>
<td>
create a new self-extracting archive file called Package.exe, adding
all files within the c:\files directory hierarchy.
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe Package.zip -split 1mb -d c:\files -r+ *.*</td>
</tr>
<tr>
<td> </td>
<td>
create a new "spanned" or multi-segment zip file called Package.zip, adding
all files within the c:\files directory hierarchy. Each segment of the zipfile should be
limited to 1mb in size, and the segments will be named Package.z01, Package.z02, etc.
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe ImageLibrary.zip -split 1mb -d c:\images -r+ "name = *.jpg AND size > 100kb"</td>
</tr>
<tr>
<td> </td>
<td>
create a new "spanned" or multi-segment zip file called ImageLibrary.zip, adding
all .jpg files within the c:\images directory hierarchy that have a size larger than 100kb. Each segment of the zipfile should be
limited to 1mb in size, and the segments will be named Package.z01, Package.z02, etc.
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe Portfolio.zip -p Secret! -aes -d c:\portfolio -r+ "name != *.tfs"</td>
</tr>
<tr>
<td> </td>
<td>
create a new aip file called Portfolio.zip, adding
all files within the c:\portfolio directory hierarchy that do not have the .tfs extension.
Encrypt all entries using AES 256-bit encryption.
</td>
</tr>
<tr>
<td colspan='2' class="code">zipit.exe Portfolio.zip -p Secret! -aes -L 9 -d c:\portfolio -r+ "name != *.tfs"</td>
</tr>
<tr>
<td> </td>
<td>
create a new aip file called Portfolio.zip, adding
all files within the c:\portfolio directory hierarchy that do not have the .tfs extension.
Encrypt all entries using AES 256-bit encryption, and use level 9 (Best) compression.
</td>
</tr>
</table>
<!-- ============================================================== -->
<h3>Syntax for the Selection Criteria</h3>
<p> Using the a selector string, you can specify a set of criteria for
the files to be added to the zip file. Specify the criteria in
statements of 3 elements: a noun, an operator, and a value. Consider
the string "name != *.doc" . The noun is "name". The operator is "!=",
implying "Not Equal". The value is "*.doc". That criterion, in
English, says "all files with a name that does not end in the .doc
extension." </p>
<p> Supported nouns include <b>name</b> for the filename; <b>atime</b>,
<b>mtime</b>, and <b>ctime</b> for last access time, last modfied time,
and created time of the file, respectively; <b>attributes</b> for the
file attributes; and <b>size</b> for the file length (uncompressed).
The <b>attributes</b> and <b>name</b> nouns both support = and != as
operators. The <b>size</b>, <b>atime</b>, <b>mtime</b>, and
<b>ctime</b> nouns support = and !=, and >, >=, <, <= as
well. The times are taken to be expressed in <em>local time</em>. </p>
<p> Specify values for the file attributes as a string with one or more
of the characters H,R,S,A in any order, implying Hidden, ReadOnly,
System, and Archive, respectively. To specify a time, use
YYYY-MM-DD-HH:mm:ss or YYYY/MM/DD-HH:mm:ss as the format. If you omit the HH:mm:ss portion, it
is assumed to be 00:00:00 (midnight). The value for a size criterion is
expressed in integer quantities of bytes, kilobytes (use k or kb after
the number), megabytes (m or mb), or gigabytes (g or gb). The value for
a name is a pattern to match against the filename, potentially including
wildcards. The pattern follows CMD.exe glob rules: * implies one or
more of any character (not including dot), while ? implies one character
(not including dot). If the name pattern contains any slashes, it is
matched to the entire filename, including the path; otherwise, it is
matched against only the filename without the path. This means a
pattern of "*\*.*" matches all files one directory level deep, while a
pattern of "*.*" matches all files in all directories. </p>
<p> To specify a name pattern that includes spaces, use single quotes
around the pattern. A pattern of "'* *.*'" will match all files that
have spaces in the filename. The full criteria string for that would be
"name = '* *.*'" . </p>
<!-- ============================================================== -->
<h3>Examples of Selection Criteria</h3>
<table border='1'>
<tr>
<td style='color:white;Background:Navy;'><strong>Use this Command...</strong></td>
<td style='color:white;Background:Navy;'><strong>to do this...</strong></td>
</tr>
<tr>
<td colspan='2' class="code">name = *.jpg</td>
</tr>
<tr>
<td> </td>
<td>any .jpg file
</td>
</tr>
<tr>
<td colspan='2' class="code">mtime > 2009-07-14</td>
</tr>
<tr>
<td> </td>
<td>any file with a <em>last modified time</em> after midnight on 14 July
2009. There is also ctime and atime for <em>created time</em> and <em>accessed
time</em>.
</td>
</tr>
<tr>
<td colspan='2' class="code">ctime > 2009-07-14-07:53:00</td>
</tr>
<tr>
<td> </td>
<td>any file with a <em>created time</em> after 7:53am (local time) on 14 July 2009.
</td>
</tr>
<tr>
<td colspan='2' class="code">size > 320mb</td>
</tr>
<tr>
<td> </td>
<td>
any file with a size over 320mb. You can use <b>kb</b> or <b>gb</b>, too. Or
omit the characters to specify a filesize in bytes. And you can use <, >, or = as
operations.
</td>
</tr>
<tr>
<td colspan='2' class="code">attr != H</td>
</tr>
<tr>
<td> </td>
<td>
any file that does not have the Hidden attribute set. Other attributes
include S=system, R=Readonly, A=Archive. Of course you can test that
the attribute is ON as well, using = instead of !=.
</td>
</tr>
<tr>
<td colspan='2' class="code">attr != H and size > 320mb</td>
</tr>
<tr>
<td> </td>
<td>
include the files that satisfy both conditions. You can also use OR as a conjuction. Use parens to group complex expressions.
</td>
</tr>
<tr>
<td colspan='2' class="code">name = *.jpg or name = *.gif</td>
</tr>
<tr>
<td> </td>
<td>
include the files that satisfy one or the other condition.
</td>
</tr>
<tr>
<td colspan='2' class="code">(name = *.jpg) or (name = *.gif)</td>
</tr>
<tr>
<td> </td>
<td>
same as above.
</td>
</tr>
<tr>
<td colspan='2' class="code">(mtime >= 2009-07-01) and (mtime < 2009-07-02)</td>
</tr>
<tr>
<td> </td>
<td>
any file modified on July 1st. From midnight to midnight.
</td>
</tr>
<tr>
<td colspan='2' class="code">(name = *.jpg) AND (mtime >= 2009/07/01) and (mtime < 2009/07/02)</td>
</tr>
<tr>
<td> </td>
<td>
any .jpg file modified on July 1st.
</td>
</tr>
<tr>
<td colspan='2' class="code">(name = *.jpg) and (size >= 100kb) and (mtime >= 2009/07/01) and (mtime < 2009/07/02)</td>
</tr>
<tr>
<td> </td>
<td>
any .jpg file, 100kb or more in size, modified on July 1st.
</td>
</tr>
</table>
<!-- ============================================================== -->
<h2>UnZip.exe</h2>
<p>This tool can be used to view, extract, or test and verify ZIP files,
from the command line or from a batch file. </p>
<!-- ============================================================== -->
<h3>Usage</h3>
<pre>
UnZip.exe [options] <zipfile> [<entryname>...]
unzips all files in the archive.
options:
-o overwrite existing files if necessary.
-f flatten directory structure when extracting.
-p <password> specify password for extraction.
-t test the file for consistency.
-q operate quietly (no verbose messages).
-cp <codepage> extract with the specified numeric codepage. Only do this if you
know the codepage, and it is neither IBM437 nor UTF-8. If the
codepage you specify here is different than the codepage of
the cmd.exe, then the verbose messages will look odd, but the
files will be extracted properly.
-d <directory> unpack to the specified directory. If none provided, it will
unzip to the current directory.
<entryname> unzip only the specified filename.
unzip -l <zipfile>
lists the entries in the zip archive.
unzip -i <zipfile>
displays full information about all the entries in the zip archive.
unzip -t <zipfile> [-p <password>] [-cp <codepage>]
tests the zip archive.
unzip -?
displays this message.
</pre>
<h3>Command Examples</h3>
<table border='1'>
<tr>
<td style='color:white;Background:Navy;'><strong>Use this Command...</strong></td>
<td style='color:white;Background:Navy;'><strong>to do this...</strong></td>
</tr>
<tr>
<td colspan='2' class="code">UnZip.exe -l Package.zip </td>
</tr>
<tr>
<td> </td>
<td>
list the entries in the zipfile, along with basic information about each entry.
</td>
</tr>
<tr>
<td colspan='2' class="code">UnZip.exe Package.zip </td>
</tr>
<tr>
<td> </td>
<td>
extract the entries in the zipfile, into the current directory.
</td>
</tr>
<tr>
<td colspan='2' class="code">UnZip.exe Package.zip -d ex1 </td>
</tr>
<tr>
<td> </td>
<td>
extract the entries in the zipfile, into the directory 'ex1'. The directory will
be created if it does not exist.
</td>
</tr>
<tr>
<td colspan='2' class="code">UnZip.exe Package.zip -f -d ex1 </td>
</tr>
<tr>
<td> </td>
<td>
extract the entries in the zipfile, into the directory 'ex1'. The directory will
be created if it does not exist. Any directory hierarchy within the zip file
will be ignored or "flattened" upon extraction.
</td>
</tr>
<tr>
<td colspan='2' class="code">UnZip.exe Package.zip -o -d ex1 </td>
</tr>
<tr>
<td> </td>
<td>
extract the entries in the zipfile, into the directory 'ex1'. The directory will
be created if it does not exist. During extraction, any existing files in the
directory hierarchy will be overwritten if necessary.
</td>
</tr>
</table>
</body>
</html>