This worked for me in the bash shell. If I tried to default the dirNUM to 3 digits first then I would error out with the 08 errors.
Code:
      dirNUM=1
      until [[ $dirNUM == 367 ]]
      do
         # Change directory number to 3 digits
         if [[ ! -d ${root_dir}/$(printf "%.3d" $dirNUM) ]]
         then
            mkdir ${root_dir}/$(printf "%.3d" $dirNUM)
...