Login  Register

Re: save all opened images and changing their name

Posted by Herbie on Apr 04, 2016; 9:23am
URL: http://imagej.273.s1.nabble.com/save-all-opened-images-and-changing-their-name-tp5016055p5016057.html

Inesica,

you may have a look at the text handling functions of the ImageJ macro
language:

<http://rsb.info.nih.gov/ij/developer/macro/functions.html>

Is this the desired text-translation?
Stack_Reg-0001 >  z0000_t0000
Stack_Reg-0002 >  z0001_t0000
...

Here is an example snippet:
name = "Stack_Reg-0002";
number = parseInt( replace( name, "Stack_Reg-", "" ) );
number--;
if ( number < 10 ) { name = "z000"; } else { name = "z00"; }
name += "" + number + "_t0000";
print( name );

HTH

Herbie

:::::::::::::::::::::::::::::::::::::
Am 04.04.16 um 10:26 schrieb inesica:

> Hello everybody. I am new to ImageJ, so I would need your help. I want to
> save all my opened images that are called: Stack_Reg-0001, Stack_Reg-0002
> etc. I used a macro from a previously asked question about this:
>
> // get image IDs of all open images
> dir = getDirectory("Choose a Directory");
> ids=newArray(nImages);
> for (i=0;i<nImages;i++) {
>          selectImage(i+1);
>          title = getTitle;
>          print(title);
>          ids[i]=getImageID;
>
>          saveAs("tiff", dir+title);
> }
>
> However, since I am using a matlab program that needs the files with a
> certain name, I need to change their name. I would like to have them as:
> z0000_t0000, z0001_t0000, z0002_t0000 etc, until z0024_t0000. Is it possible
> to do this in the macro?
> Thank you very much in advance.
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/save-all-opened-images-and-changing-their-name-tp5016055.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html