I am running the following code
for d in ./*/ ; do (cd "$d" && dcm2nii -n y -r y -x y -g n ../*/dicom/); done;
in order to execute the dcm2nii program on all subfolders of ./*/ (they are all titled "dicom") and to save the output to those same subfolders. The loop works but it runs twice creating duplicate output files within each "dicom" subfolder. Interestingly, if I specify absolute paths in both places, but with the wildcard * intact to include all folders within the parent directory, the loop runs only once as desired. How can I get the loop to run only once using relative paths?