Print number with expected decimals


Hi all,

Stupid question but I haven’t yet found the answer…

I am looping through a multi dimensional file and want to save them all individually.
However, I was wondering if it was possible to force the number of number for the current iteration in the loop.

To be more clear, in the loop from 0 to 9, there will only be 1 number, from 10 to 99 2 numbers, from 100 to 999 3 etc… Would it be possible to fix that and have “001” instead of “1” ?

Thanks for your help :slight_smile:


Use the IJ.pad(n, length) macro function or, from scripts, the same function available from the IJ API.


Thanks! I knew there was something but I couldn’t find it again…