Re: macro rename files simple

Posted by inesica on
URL: http://imagej.273.s1.nabble.com/macro-rename-files-simple-tp5016330p5020204.html

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