Posted by
CARL Philippe (LBP) on
Mar 05, 2018; 12:33pm
URL: http://imagej.273.s1.nabble.com/macro-rename-files-simple-tp5016330p5020206.html
Dear Inesica,
Probably one of the most important rule when you are debugging a code, is to use and highly abuse with outputs (in the macro language outputs are done with the instruction print) where you compare these output with what you were actually expecting.
And remember: "practice makes perfect"!!!
My best regards,
Philippe
-----Message d'origine-----
De : ImageJ Interest Group [mailto:
[hidden email]] De la part de Herbie Envoyé : lundi 5 mars 2018 12:57 À :
[hidden email] Objet : Re: macro rename files simple
Good day!
Replace line "number += m;" by "number /= 2;" (of course without the inverted commas) and please try to learn macro coding which is really easy:
<
https://imagej.nih.gov/ij/developer/macro/macros.html>
<
https://imagej.nih.gov/ij/developer/macro/functions.html>
Regards
Herbie
:::::::::::::::::::::::::::::::::::::
Am 05.03.18 um 11:15 schrieb inesica:
> Hello, could you help me with another problem that I have renaming
> ImageJ files? I try to adapt the macro you gave me earlier, but I seem
> to be missing something. My files have these names: z0000_t0000,
> z0000_t0002,
> z0000_t0004 etc (until z0032_t0080) and I would like to rename
> z0000_t0002 to z0000_t0001; z0000_t0004 to z0000_t0002 etc; which
> basically means divide the number at the end by 2. So I adapted your
> function to:
>
> setBatchMode( true );
> *m = /2; *
> dirPath = getDirectory( "Choose a Directory" ); nameArray =
> getFileList( dirPath ); for ( i = 0; i < nameArray.length; i++ ) {
> number = parseInt( substring( nameArray[i], 7, 11 ) );
> number += m;
> name = substring(nameArray[i], 0, 6) + "t" + IJ.pad( number, 4 ) +
> ".tif";
> status = File.rename( dirPath + nameArray[i], dirPath + name );
> if ( status == false ) { exit( "Could not rename" ); } }
> setBatchMode( false );
>
>
> but it does not seem to work. How can I change it to make it work?
>
> Thank you very much in advance.
>
>
>
> --
> Sent from:
http://imagej.1557.x6.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