You can do it with DotNetZip - it was originally produced as a library for use by programmers but the sample apps built on and shipped with the library have become very useful in their own right.
One of the "samples" is called zipit.exe - a console tool. Specify a non-existent zipfile to create a new one, or specify an existing zipfile to update it.
zipit.exe ZipArchive.zip c:\data\folder1
You can specify one or more filenames, directories, or a logical expression that describes which files to include. For the expressions:
name = *.jpg
any .jpg file.
mtime > 07/01/2009
any file with a last modified time after midnight on 1 July 2009. There is also ctime and atime for created time and accessed time.
ctime > 07/01/2009:07:53:00
any file with a created time after 7:53am on 1 July 2009.
size > 320mb
any file with a size over 320mb. You can use kb or gb, too. Or omit the characters for a size in bytes. And you can use < or = as operations.
attr != H
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 !=).
attr != H and size > 320mb
include the files that satisfy both conditions. You can also use OR as a conjuction. Use parens to group complex expressions.
name = *.jpg or name = *.gif
include the files that satisfy one or the other condition.
(name = *.jpg) or (name = *.gif)
same as above.
(mtime >= 07/01/2009) and (mtime < 07/02/2009)
any file modified on July 1st. From midnight to midnight.
(name = *.jpg) AND (mtime >= 07/01/2009) and (mtime < 07/02/2009)
any .jpg file modified on July 1st.
(name = *.jpg) and (size >= 100kb) and (mtime >= 07/01/2009) and (mtime < 07/02/2009)
any .jpg file, 100kb or more in size, modified on July 1st.
With other options on the zipit.exe tool, you can also:
- specify whether you want to traverse reparse points (like symlinks or junctions, eg "My Music").
- recurse directories or not (default is NOT)
- encrypt the zip with AES or with "regular" zip encryption
- specify a segment size to produce a spanned or segmented zip file.
- produce a self-extracting archive
Examples:
zipit.exe Archive.zip -D c:\project1 -r+ "(name = *.xlsx) and (mtime >= 07/01/2009) and (mtime < 07/31/2009)"
- Produce a file, Archive.zip, that contains all the .xslx files in the c:\project1 directory hierarchy, that were modified in July.
zipit.exe Unpack.exe -sfx w -D project2 -r+ "(name = *.pdf) and (size > 100kb)"
- Produce a self-extracting GUI exe, named Unpack.exe, that contains all the .pdf files in the project2 directory hierarchy, that are larger than 100k in size.
DotNetZip is free.
All these features are available in the .NET interface of the library, too. And there's a GUI tool, too.