1 Answer
1

Well, that depends ....
If you're running Linux or a Linux-like shell (e.g. cygwin) in Windows, it's a simple program to write in bash or your favorite language like python or perl.

Here's some (untested ;) ) pseudo code (somewhat close to bash, but without a whole lot of extra needed syntax).

I=0 ##File counter
J=1 ##Archive counter
## the following while strategy will work in most languages as long as you don't
## have thousands of files - if you do, read them in 1 at a time in the loop
while FILE in <list-of-files-to zip> ## Loop across all files like *.txt
do
if I mod 3 == 0 ## If we're at the start of a new archive
then
COMMAND="7z -a archive"J".7z " FILE " " ##Start a new command line for archive "J"
J++
else
COMMAND=COMMAND FILE ##append the next file name to the command string
if I mod 3 == 2 ## if the desired number of files are appended
then
append COMMAND string to a script file to run later
or run it directly right here
COMMAND="" ## clear the COMMAND string
fi
fi
I++
done
## Handle left over files
I-- ## Loop increments I after last file
if I mod 3 != 2
then
append COMMAND string to a script file to run later
or run it directly right here
fi

You can change the "3" to a variable (SIZE) to build archives with a different number of files. If you do do, then the "2" becomes SIZE-1.

Thank you for your efforts and sorry for not pointing out I use Windows 7. I have got a perfect solution from stackflow but I'm sure your script will be helpful if I start to use cygwin someday:D
–
WTFIsGoingOnOct 8 '11 at 6:56