Tuesday, January 17, 2017

#1 2005-10-21 06:23:02 am

julifos
Administrator
From: MalasaƱa, Madrid
Registered: 2002-11-20
Posts: 2014

How do I add leading zeroes to a number?

For example, you are renaming files, and you would like better "0001" instead of "1", so the visual look is fine when you browse the folder. Then, you can use this old trick:

Applescript:

set theNumber to 1

text -4 thru -1 of ("0000" & theNumber) --> "0001"

Basically, you add some leading zeroes to theNumber (which could be 1 or 7895), you are converting the "thing to manipulate" to string, then extracting the last four characters (this would return, of course, "7895" if you input 7895, and "0127" if you input 127).

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.028 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)