We would like to zip the files in directory with number of records along with directory naming convention to follow the zip file.
Ex: we have two directories with date names (2021-10-01, 2021-10-02 and each of this parent directories contains sub directories with country names and this country directories contains number of files.
2021-10-01/USA, 2021-10-01/UK
2021-10-02/USA, 2021-10-02/USA 
And we would like to zip the country directories with limited number of records and and zip file should name as parentdirectory_Countrydirectory.zip(2021-10-01_USA.zip).
And My script accept the dates as parameter and which will pass it to sql query which will extract data with dates parent directory structure with country sub-directories inside the data with files from DB but I am just skipping the sql query part of my script here.
#!/bin/bash
startd=$1
endd=$2
compress () {
 startd=$(date -d $startd +%Y%m%d)
        endd=$(date -d $endd +%Y%m%d)
        while [[ $startd -le $endd ]]
        do
           tempdate=$(date -d $startd +"%Y-%m-%d")
           dirl+=" $tempdate"
           startd=$(date -d"$startd + 1 day" +"%Y%m%d")
        done
        echo $dirl
 for j in $dirl
 do
    if [ -d "$j" ]; then
       cd $j
       for d in *
       do
           zip ${j}_${d}.zip $d
           mv ${j}_${d}.zip ../
       done
     else
       echo "no data extracted on: $j"
     fi
   cd ..
 done
}
I would like to zip the files with limit of number of records and name could be parentdirectory_subdirectory1.zip with incremental of the number with same naming convention.
Note: Number of records means files in the sub directories which is extracted by sql query , USA sub-directory may contains thousand of files so I would wanted to split the zip with sub directory files like 200 files then create the file with same naming convention like 2021-10-01_USA.zip 2021-10-01_USA1.zip etc.
 
    