Hello all,
I asked this in the basic Unix forum got no answer since one week.
So I believe this is an advanced level question hence posting it here.
Any suggestions welcome.
I have a directory of files of varying sizes.
I want to copy all these files in n number of threads to another directory such that each
copy set is more or less the same size.
Example :
Say /mydirA
It has around say 23 files of various sizes.
Number of copy threads say = 3
total directory size of /mydirA = 25 GB
So each thread should copy files whose sizes add up to almost 25/3 ~ 8 GB
So need to gather files based on the size for each thread such that they add upto 8GB
Thread 1 --> 8GB ..could be 11 files which add up to 8 gb
Thread 2 -->8 Gb ... couldbe 5 files which add up to 8 gb
Thread 3 ---> 9GB ...could be 8 files which add up to 8 or 9 gb
Want roughly equal copy set threads. It is also possible that even though I select 3 threads of equal size because of lack of number of files not all 3 threads could satisy the 8gb copy set size. So atleast try to fulfill the copy set thread size as far as possible.
All files need to go from /mydirA to /mydirB in N threads bases on the size of each thread as
(Total size of directory)/N which could have different number of files in each thread based on size to add up to the individual copy thread size