What command can I use to create zip
s with a file number limit? I have a folder (no subfolders) of, say, 5000 files, so I would want a command that could divide that number and create 10 individual zip
archives, each consisting of no more than 500 files.
I also don't want the resulting 10 zip
files to be connected with each other, so that I can open them individually and won't need to open all 10 at the same time.
Best Answer
You can use GNU parallel to do that as it can limit the number of elements to a job as well as provide a job number (for a unique zip archive name):
The option
-N 5
limits the number of files to 5 per archive and is presented tozip
in place of{}
The
{#}
(verbatim, not to be replaced by you during the invocation), is replaced by the job number, resulting inarch1.zip
,arch2.zip
etc.The
-print0
option tofind
and-0
option toparallel
in tandem make sure that filenames with special characters are correctly handled.