////This file is read only and needs to be saved under a different name. Save it as text only to run it as a macro in ImageJ.

////This file will look for image sequences with the base name 01.tif, 02.tif until 06.tif and will load the channels c0-c6

////If you have other channels, you have to replace or add corresponding lines

////Make sure that no spaces or other strange characters are in your files or folder-names!



  dir = getArgument();

  if (dir=="")

      dir = getDirectory("Select a Directory");

      dir2 = dir;

      dir3 = "O:\\stacks-transferred\\";



for (n=1; n<20; n++)

{



      dir = dir2 + "0" + n + ".tif_Files";

  if (!(endsWith(dir, "/")||endsWith(dir, "\\")))

      dir = dir + "/";

    

      list = getFileList(dir);

    

    

     

for (i=0; i<list.length; i++)

{

     if (endsWith(list[i], "00c0.tif"))

    {

      run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c0");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }

      

    if (endsWith(list[i], "00c1.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c1");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }

      

          if (endsWith(list[i], "00c2.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c2");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }



    if (endsWith(list[i], "00c3.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c3");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }



    if (endsWith(list[i], "00c4.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c4");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }



    if (endsWith(list[i], "00c5.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c5");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }

    

    if (endsWith(list[i], "00c6.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=c6");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }

    

    if (endsWith(list[i], "z00.tif"))

    {

    run("Image Sequence...", "path='"+dir+list[i]+"' number=362 starting=1 increment=1 scale=100 file=.tif");

    list2 = list[i] + "_.tif";

    run("Tiff...", "save='"+dir3+list2+"'");

    close();

    }



}

}