Delete symbo for the active file

Hello,

I have a list folder of named “ROI_01”, “ROI_02”, etc. These folders contain sequences of images. I wrote a macro to get series of images from the folder and save it as series to another directory. But I need to save the series as the name “ROI01”, “ROI02”. Simply delete the “_” in the filename. Below is my macro. Unfortunately, the imagej did not do anything for the first “rename” command.

input = getDirectory("Input directory");
output = getDirectory("Output directory");

processFolder(input);

function processFolder(input) {
	
	list = getFileList(input);
	
	
	for (i=0; i<list.length; i++) {

		if(File.isDirectory(input + list[i])==1);{
			fileList=getFileList(input + list[i]);
			
			fileList=Array.sort(fileList);
			fileListFirst=fileList[0];
			}
		
		run("Image Sequence...", "open=["+input+list[i]+fileListFirst+"] file=.tif sort");
                rename(replace(list[i],"_",""));
		rename(replace(list[i],"/","_"));
		run("Image Sequence... ", "format=TIFF save=["+output+"]");
close("*");
} 

}

That seems odd. Perhaps it is due to some syntactical errors in your script? You don’t need the semi-colon between the condition of the if statement and the execution block. I am not sure if that has any negative impact but it certainly isn’t needed. Also, when checking to see if the name in list refers to a directory, you don’t need ==1. The function you are using returns a boolean which Java (and thus the macro language) uses directly. In fact, having == could possibly be forcing unnecessary computations as it may be converting the boolean to an integer and then performing the comparison to reproduce the boolean.