Login  Register

Re: Pls: on ImageJ and rename a file

Posted by Ben Tupper on Jan 16, 2009; 7:23pm
URL: http://imagej.273.s1.nabble.com/Macro-help-result-file-save-tp3694038p3694041.html

Hi,

The getInfo() macro function will return the information.  Then use  
the rename() function to rename the image. Here's how to rename the  
image with its height info.

run("Blobs (25K)");
run("Show Info...");
info = getInfo()
x = split(info, "\n");
rename(x[3]);



Cheers,
Ben


On Jan 16, 2009, at 2:12 PM, Juan Francisco wrote:

> Dear all:
> I try to do the following:
> once a image is opened (a dicom format) , I would like to rename  
> its original name to be replaced by a specific caracter sequence  
> (string) of a line of the Show Info .
> Pls, is ther some way to do this with ImageJ in a automatic fashion?
> Thank yu evry much for your kindness
> JFC
>
> --- El jue, 15/1/09, Wayne Rasband <[hidden email]> escribió:
>
> De: Wayne Rasband <[hidden email]>
> Asunto: Re: Macro help - result file save
> Para: [hidden email]
> Fecha: jueves, 15 enero, 2009 5:52
>
> On Jan 15, 2009, at 10:57 AM, Wu, Yuhong wrote:
>
>> Hi All,
>>
>> I have a question regarding writing macro to save result files from
>> "analyze particle".
>>
>> As an exmaple, I can open an image and run analyze particle and save
>> measurements into an excel file in a pre-defined folder with a
>> pre-defined name : saveAs("Measurements",
> "C:\\Documents and
>> Settings\\Desktop\\Results.xls"); ".
>>
>> But what I would like to do is to use getDirectory("image") and
>> getTitle("image") so to save the excel file:
>> (1) in the folder that contains the image and
>> (2) with a title that reflects the image being analyzed, say "Results
> -
>> xx.xls" (xx is the image name).
>>
>> For some reason, I can create new images and save those as I  
>> wanted. But
>> not for the results.xls files.
>>
>> Any help is greatly appreciated -  thanks in advance!
>>
>> Yuhong
>
> Here is macro that does this. It removes the extension from the  
> image title and
> replaces it with ".xls" because saveAs("Measurements", path)
> doesn't do it, although it probably should.
>
>   open("");
>   run("Measure");
>   dir = getDirectory("image");
>   name = getTitle;
>   index = lastIndexOf(name, ".");
>   if (index!=-1) name = substring(name, 0, index);
>   name = name + ".xls";
>   saveAs("Measurements", dir+name);
>   print(dir+name);
>
> -wayne
>
>
>
>