don't use a loop in a script shell when you can use Snakemake or Nextflow
People need to start somewhere. Loops -> xargs/parallel -> snakemake/nextflow is the logical progression in learning automation IMO.
I find it weird that OP uses a mix of ${} and "..."/"...." (multiple quoted strings interleaved with multiple unquoted strings). Why not simply "${sbam}/${bamfile%_sorted.bam}_metrix"?