File.nameWithoutExtension Help/Error

I am running into an issue with the function File.nameWithoutExtension in the ImageJ/Fiji macro language. I am using Fiji specifically to create a macro that opens a series of files in a directory, creates a directory with the same name (minus the extension) of each file in the original directory, performs some analysis on the files and saves various result files in the individual directories matching the original file name. My problem is that when I do this on my computer at work, a Windows7 pc installation of Fiji, everything works just fine with the function. However, when I work on the same macro at home, the File.nameWithoutExtension function does not give me the file name but the name of the parent directory instead. This, of course, leads to errors when the second file in the directory is processed.

Here is the function I’ve created in the macro to process each file in the directory:

//Function to process each individual file.
function processFile(inputDirectory, inputFile) {
        //Create a directory for output files.
	separatorCharacter = File.separator;
	fileNoExtension = File.nameWithoutExtension;
	outputDirectory = inputDirectory + fileNoExtension;

	//Scale the image.
	scaleImage(inputDirectory, inputFile);

	//Create the well mask.
	createWellMask(outputDirectory, inputFile);

	//Create colony mask.
	createColonyMask(outputDirectory, inputFile);

After running this function in the macro, the variable fileNoExtension is a string equal to the file name without the extension in Windows but equal to the parent directory in OSX.

Has anyone seen this before? I have not found any mention of it, so I assume it has something to do with my installation of Fiji on my Mac, but I am stumped as how to solve it.

Thanks for any help you can offer.

1 Like

Please provide a small runnable macro that reproduces this problem. The following macro outputs the file name without the extension, as expected, on my Mac running OS X 10.10.5:

newImage("Untitled", "8-bit ramp", 500, 500, 1);
path = getDirectory("home")+"Downloads/Untitled.tif";
saveAs("Tiff", path);
fileNoExtension = File.nameWithoutExtension;
1 Like