# Batch converting .img files to .mgz in FreeSurfer

I have a series of .img files from a previous analysis in SPM that Freesurfer (FS) cannot directly handle.

FS comes with a conversion tool, the mri_convert command, but I am not able to make it run iteratively over all the files in the same directory. I found a mention about the --sdcmlist argument online, however I am not figuring out the proper syntax for it.

When I run:

mri_convert --sdcmlist 000123_1_4.img 000123_1_4.mgz


I get:

mri_convert: missing output volume name


Would anyone suggest a way of going about these conversions?

for f in *.img; do mri_convert $f$f.mgz; done