Batch Processing error

Hello everyone, I am applying mrthreshold to obtain a binary image from a density image. I want to perform this processing for each of the subfolders I have.

The folders are organized as follows:


I want the binary image to be saved with the same name as the folder + _50.nii.gz, that is, AF_left_50.nii.gz. To do this, I am using the for_each command, which worked correctly but had some issues for certain folders.

for_each TractSeg_64_atlas/* : mrthreshold IN/PRE_sum.nii.gz -abs 32 IN/PRE_50.nii.gz