Is there a way to set the output format in the Process -> Batch -> Macro function to ".txt"?

I have a Macro that finds the X and Y coordinates of an outline that I want to run on a number of images, and I need the X and Y coordinates to be saved as a .txt files. The Batch macro command doesn’t allow to choose the output format as .txt, however. Is there a way to somehow add such option?

Thank you.


So… I’m not sure about how you are getting your coordinates, etc… Perhaps if you can next time - post at least the relevant section of the macro code you are developing?

But I came up with this quick&dirty macro that should allow you to save coordinates that are printed to the log window. I used the Built In Macro Functions list to help me come up with this solution (it’s a helpful link to save as a resource).

#@File(label = "Output directory", style = "directory") output

run("Blobs (25K)");
makeLine(55, 74, 179, 177);
roiManager("Select", 0);
getSelectionCoordinates(x, y);
for (i=0; i<x.length; i++) {
	print(i+" "+x[i]+" "+y[i]);
//saves results in txt file
saveAs("Text", output + "LogWindow.txt");

This script also takes advantage of Script Parameters - will make your life a whole lot easier! :slight_smile:

If this works or not - let us know. We can adapt accordingly…

eta :slight_smile:


Yes, sorry about that. This is the macro I am using:

name = getTitle();
h = getHeight();
run(“Fit Spline”);
getSelectionCoordinates( x, y );
tabDelText = “”;
for ( i = 0; i < x.length; i++ ) {
tabDelText += “” + x[i] + “\t” + h - y[i] + “\n”;
path = getDirectory( “Choose a Directory” )+name;
File.saveString( tabDelText, path + “.txt” );

My problem is that when I use the built in Batch function in ImageJ, there is no output option for saving the data as a .text file.