Login  Register

Re: save all opened images and changing their name

Posted by CARL Philippe (LBP) on Apr 04, 2016; 11:37am
URL: http://imagej.273.s1.nabble.com/save-all-opened-images-and-changing-their-name-tp5016055p5016058.html

Dear Herbie,
You can replace your:
If ( number < 10 ) { name = "z000"; } else { name = "z00"; }; name += "" +
number + "_t0000";
By:
name = "z" + IJ.pad(number, 4) + "_t0000"; print(name);
Kindest regards,
Philippe

Philippe CARL
Laboratoire de Biophotonique et Pharmacologie
UMR 7213 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84


-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de Herbie
Envoyé : lundi 4 avril 2016 11:35
À : [hidden email]
Objet : Re: save all opened images and changing their name

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-t
> heir-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

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