Open my file once

Hello,

With your help I found how to automatically open a file. Now I want the file that I have already opened and edited, no longer open. Can you help me with this?
The code for to open the different files is this:

chosenDirectory = getDirectory("Choose your super folder ");

processFiles(chosenDirectory); *//necessary to run the function*

//define the function

function processFiles(currentDir) {

   fileList = getFileList(currentDir);

   for (i=0; i<fileList.length; i++) {
      if (startsWith(fileList[i], "5_TSE") || startsWith(fileList[i], "6_TSE")) {
         open(currentDir+fileList[i]);
         //here goes your processing code
      } else if (endsWith(fileList[i], "/")) {
         processFiles(currentDir + fileList[i]);
      }
   }
}

Dear @Yasmine_student,

you just add close(fileList[i]); after it is processed (basically before the else part.

You can learn more on the macros language from the following 2 pages where all commands are explained in detail and examples are given:

https://imagej.net/developer/macro/functions.html

https://imagej.net/developer/macro/macros.html

https://imagej.net/developer/index.html

Hope that helps to get kick-started in modifying your macros

Thank you, It’s really dificult to understand this when you don’'t have background about it.

I will check this pages out

1 Like

Sure, this is perfectly normal. But don’t worry. Many of us started exactly like you with small code examples and making step-by-step advances. This takes a little bit of time and in the beginning you will see a lot of error messages or things will not work out. Also that is normal. Most importantly, do not get frustrated by those issues and keep trying. Finally, you always can ask questions here. But it will be easier for you to understand the answers you receive by building up a knowledge base with those resources, information and example macros. If a video is easier for you to learn, you can also watch this link as an introduction to get some basic understanding: ImageJ/Fiji Macro Language - [NEUBIASAcademy@Home] Course - YouTube