Formatting a numeric attribute as fixed width string for use in renamer

Started by ubacher, March 18, 2014, 12:58:29 PM

Previous topic - Next topic

ubacher

I can display a numeric attribute in the TEXT field of the renamer.
However I would need the numbers to display with fixed width i.e. leading zeroes to be
useful. Is there a way to do this or should I make a feature request?

Something like:
{File.AT.Image.PageSequenceNr|Format:000}

sinus

Quote from: ubacher on March 18, 2014, 12:58:29 PM
I can display a numeric attribute in the TEXT field of the renamer.
However I would need the numbers to display with fixed width i.e. leading zeroes to be
useful. Is there a way to do this or should I make a feature request?

Something like:
{File.AT.Image.PageSequenceNr|Format:000}

I am not sure, what you want.

But the variable (for example)

000{Application.Version}

gives

0005.0.146

or

00-{File.Height}
gives

00-3'264
Best wishes from Switzerland! :-)
Markus

ubacher

I like to get output like:
001,010,012,026,100,123,145,......

instead of 1,10,12,26,100,....

sinus

Quote from: ubacher on March 18, 2014, 02:46:12 PM
I like to get output like:
001,010,012,026,100,123,145,......

instead of 1,10,12,26,100,....

So I have no idea. I created my workflow, so that I have not this problem.
But of course, I understand, that one will have better

001
002
..
010
011
..
214
215

than
1
2
10
214
Best wishes from Switzerland! :-)
Markus

Mario

Quote from: ubacher on March 18, 2014, 02:46:12 PM
I like to get output like:
001,010,012,026,100,123,145,......

instead of 1,10,12,26,100,....

A quick look in the help file  under Formatting Variables reveals the numformat function which does what you need. Please see the help for details.

{File.AT.Set.Attr|numformat:int,04}

returns:

0001

if the Attribute is 1
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on March 18, 2014, 03:58:53 PM
Quote from: ubacher on March 18, 2014, 02:46:12 PM
I like to get output like:
001,010,012,026,100,123,145,......

instead of 1,10,12,26,100,....

A quick look in the help file  under Formatting Variables reveals the numformat function which does what you need. Please see the help for details.

{File.AT.Set.Attr|numformat:int,04}

returns:

0001

if the Attribute is 1

Cool.
Yep, read the f... antastic manual ;)

I guess, this will do, what ubacher want.
Best wishes from Switzerland! :-)
Markus

ubacher

I did RTFM:
numformat: Type, Width{,Decimals}   This function allows you to cast (convert) the contents of a variable into an int or float numerical data type,

This is where I stopped reading thinking this is not what I wanted. Had I read on I might have picked up that it works also the other way:
convert a numeric variable into a string.

Mario

You are converting the value of the variable (which is always a string) into a numeric type temporarily, and then re-format it into a string using the given width and decimals.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook