node-bestzip icon indicating copy to clipboard operation
node-bestzip copied to clipboard

Delete exists before create options ?

Open abcfy2 opened this issue 4 years ago • 1 comments

Native zip behavior is update exists zip file. We should add a option like delete exists before create. Thanks.

From man zip description:

       where archive is a new or existing zip archive and inpath is a directory or file path optionally including wildcards.  When given the name of an existing zip archive, zip will replace iden‐
       tically named entries in the zip archive (matching the relative names as stored in the archive) or add entries for new names.  For example, if foo.zip  exists  and  contains  foo/file1  and
       foo/file2, and the directory foo contains the files foo/file1 and foo/file3, then:

              zip -r foo.zip foo

       or more concisely

              zip -r foo foo

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

       So if before the zip command is executed foo.zip has:

               foo/file1 foo/file2

       and directory foo has:

               file1 file3

       then foo.zip will have:

               foo/file1 foo/file2 foo/file3

       where foo/file1 is replaced and foo/file3 is new.

abcfy2 avatar Aug 06 '21 16:08 abcfy2

I find a simple solution:

zip -r - . > ../data.zip

See: https://unix.stackexchange.com/questions/299161/unix-zip-command-is-updating-existing-archive-instead-of-creating-a-new-one

abcfy2 avatar Aug 06 '21 16:08 abcfy2