Convert spider stk files to tiff file in batch?

Hi,

I have about 100 hundred SPIDER file (.stk) in one folder, each of which contains a sequence of images. I am using ImageJ to convert them to corresponding single .tiff images.

I have installed bio-formats plugin, so, for a single file, I use:
File–>open
Plugins–>Bio-formats–>Bio-formats Exporter
then export them to the expected folder.

I am trying to use Macro to process this in batch:
My code is:

dir_saving = getDirectory("saving folder")

dir_input = getDirectory("image folder")

list = getFileList(dir_input)

for(i = 0; i<list.length; i++)
{
  open(list[i]);
  savepath = dir_saving + i + '.tiff';
  run("Bio-Formats Exporter", "save=savepath write_each_z_section use compression=Uncompressed");
  close();
}

But this doesn’t work and export nothing. I think the problem is due to the savepath and the string operations. I am really new to it. Could anyone tell me how to fix it?

Thanks!!

Hi @yongshuo-Z, you may need to use:
run("Bio-Formats Exporter", "save=["+savepath+"] write_each_z_section use compression=Uncompressed");