How to pin specified folders using command line

Could you please tell me how to zip the specified files in one Zip file. Let me tell you how my folders get filled:

  • The Task Scheduler has backups of my databases and saves them to a file daily. It makes 4 database backups daily, which means there will be 4 more files daily. So I need to re-create the backups to the same zip file (of course it is different from the previous zip file, the zip file will be created for that day for the newly created backup files) and I need to do this automatically. Well, I know how to do it automatically. I can use Windows Task Scheduler to automate processes.

Thank.

+2


source to share


5 answers


You can do this with DotNetZip - it was originally released as a library for use by programmers, but the sample applications built and supplied with the library have become very useful on their own.

One of the "samples" is called zipit.exe, a console tool. Specify a non-existent zip file to create a new one, or specify an existing zip file to update it.

zipit.exe ZipArchive.zip  c:\data\folder1

      

You can specify one or more file names, directory names, or a boolean expression that describes which files should be included. For expressions:

  • name = *.jpg


    any .jpg file.

  • mtime > 07/01/2009


    any file with the time last modified after midnight July 1, 2009. There are also ctime and atime for the created time and available time.

  • ctime > 07/01/2009:07:53:00


    any file with a time created after 7:53 am on July 1, 2009.

  • size > 320mb


    any file larger than 320 MB. You can use kb or gb . Or omit characters for byte size. 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. You can of course check that the attribute is included (using = instead of! =).

  • attr != H and size > 320mb


    include files that satisfy both conditions. You can also use OR as a union. Use parens to group complex expressions.

  • name = *.jpg or name = *.gif


    include files that satisfy one condition or the other.

  • (name = *.jpg) or (name = *.gif)


    as mentioned above.

  • (mtime >= 07/01/2009) and (mtime < 07/02/2009)


    any file modified on July 1st. Midnight to midnight.

  • (name = *.jpg) AND (mtime >= 07/01/2009) and (mtime < 07/02/2009)


    jpg file modified on July 1st.

  • (name = *.jpg) and (size >= 100kb) and (mtime >= 07/01/2009) and (mtime < 07/02/2009)


    any .jpg file, size 100 kB or more, modified on July 1st.

With other options in the zipit.exe tool, you can also:

  • indicate if you want to move the reparse points (for example, symbolic links or connections, such as "My Music").
  • directories recurse or not (default is NOT)
  • encrypt zip with AES or with "regular" zip encryption
  • specify the segment size to create a spanned or segmented zip file.
  • create self-extracting archive

Examples:



zipit.exe Archive.zip -D c:\project1 -r+ "(name = *.xlsx) and (mtime >= 07/01/2009) and (mtime < 07/31/2009)"

  • Create an Archive.zip file containing all the .xslx files in the c: \ project1 directory hierarchy that were changed in July.

zipit.exe Unpack.exe -sfx w -D project2 -r+ "(name = *.pdf) and (size > 100kb)"

  • Create a self-extracting GUI exe named Unpack.exe that contains all the .pdf files in the project2 directory hierarchy that are larger than 100KB.

DotNetZip is free.

All of these functions are available in the .NET interface of the library. And then there's the GUI tool.

+5


source


I am using the open source 7Zip command line program like:

"C:\Program Files\7-Zip\7z.exe" a My.zip MyFileOrFolder

      



If you are using an NTFS partition, it might also fix your problem so that Windows will automatically compress the folder where your backup files are located (right click on your folder, select Properties, Advanced and click Compress Content to Protect data ").

+11


source


I ditched WinZip in favor of 7-Zip because it's fast, free, efficient, and available for both Windows and Linux.

If you're a WinZip fan, check out the WinZip Command Line Support Add-on: http://winzip.com/prodpagecl.htm

You can archive as many files or directories as specified in the Windows command line:

wzzip archive.zip dir1 dir2 dir3 ...

      

+3


source


You can download the GNU zip for Windows from http://gnuwin32.sourceforge.net/packages/zip.htm . If you want to get the entire UNIX command line route, a zip is available from http://www.cygwin.com/ .

There is an example on the man page that appears to address your problem, there are many other command line options:

For example, if foo.zip exists and contains foo / file1 and foo / file2, and the directory foo contains files foo / file1 and foo / file3, then:

      zip -r foo.zip foo

      

or more succinctly

      zip -r foo foo

      

will replace foo / file1 with foo.zip and add foo / file3 to foo.zip. After that, foo.zip contains foo / file1, foo / file2, and foo / file3, with foo / file2 unchanged from before.

+2


source


Take a look at an old program called PKZIP. I believe you can do this with WinZip and 7Zip as well.

+1


source







All Articles