Auto increment greater than 999 misinterpreted in renamer

Started by blinkystar, January 03, 2016, 09:48:36 PM

Previous topic - Next topic

blinkystar

Hi,

I've generated a numeric variable with auto increment , which I use in a renamer function.
Meanwhile the value of the variable exceeds 999. The next value (and all grater than thousand) in the Settings panel is shown as '1.000' (Thousand, with thousand separator).
When I use it in the renamer with numformat:int,04 it results in 0001 - and it does this for all values between 1000-1999.
I tried to change it in the Settings panel to 1000 (w/o thousand separator) manually, but the separator is back when I open Settings again.

This is what the VarToy shows:
PictInFolderCount is: {Application.Variables.PictInFolderCount} => results in: PictInFolderCount is: 1.404
PictInFolderCount|numformat:int,04 is: {Application.Variables.PictInFolderCount|numformat:int,04} => results in: PictInFolderCount|numformat:int,04 is: 0001

This destroys the renamer auto numbering of my photos.

Can you pls. tell me how to deal wiht 4-digit auto increment variables?

Thanks a lot!

Mario

IMatch automatically formats numeric variables using the locale numeric format of the current user. A variable with the numeric value 1404 will thus be emitted as 1,404 or 1.404, depending on which country you are in.

You can use cast:int to convert it into an integer.
Where did you get the ,04 from? That's not supported by the cast function and disables the cast.

Use the numformat function if you want to format numeric variables with a fixed length or width. What you probably want is something like

{Application.Variables.GlobalNum|cast:int;numformat:int,04}

This gives you something like

0001
...
0999
...
1000
1001
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Mario's answer is of course the sophisticated one.
Here the answer from a poor man:

I had the same problem, added in the renamer simply a step to remove text, in this case simply "Remove Text" and then the point (.) to remove.
This would work also, if you exceed the 9999 with 4 digits.

We have often several ways in Match to solve a problem.  ;D
Best wishes from Switzerland! :-)
Markus

blinkystar

#3
Hi Mario,

I found the information in the help at variables, formatting ->forrmatting functions. There are examples for the formatting at the end, including the numformat:int,04 :

numformat: Type, Width{,Decimals}   This function allows you to cast (convert) the contents of a variable into an int or float numerical data type, and to format the resulting number. This function is useful when you want to produce a specific number of digits from a numerical variable, e.g., in the Renamer or when using one of the export modules.


This variable always works with the raw numerical value (if available). This guarantees that you can access the full numeric precision available for a given tag.

For example, if you work with floating point variables like EXIF shutter speed, you may get values like 0.00313 (1/320s). If this value is formatted using the standard user-specific numeric prevision (2 digits), it will be formatted as 0,00. If you use a numformat with a width of 1 and a precision of 5, you get five digits after the decimal point: 0.00313.

Parameters:
Type Supported values:
int Integer number, e.g. 1
float Floating point number, e.g. 1.99
hex Hexadecimal number, e.g. 01FC

Width The number of digits to use for the output and some optional flags:- Left align the result within the given field width. By default, values are right aligned.
+ Prefix the output value with a sign (+ or –).
0 Prefix the output with zeros up to the specified width. If this is not given, the output is prefixed with blanks.

Decimals
(optional) For float values only.
Specifies the number of digits after the decimal point.

If you use decimals, the Width parameter must include these decimals as well. If you have an numformat:int,03 you get output values like "007". If you want to output the number as a float with two decimals, you need to increase the width accordingly: numformat:float,06,2 which gives in this output: "007.00".

Examples:

Assumed text in variable: 7.26 ...|numformat:int,1 7
...|numformat:int,2  7
...|numformat:int,02 07
...|numformat:int,04 0007
...|numformat:int,+04 +007
...|numformat:float,02 07
...|numformat:float,05,2 07.26
...|numformat:float,05,1 07.3
{File.MD.Composite\ShutterSpeed\ShutterSpeed\0|numformat:float,1,5}
(1/320s) 0.00313


I tried the cast function instead - at least that works :), but unfortunately it provides numbers >999 with the thousand separator, so that the filename will have an addtional dot. I will use Sinus' hint (thanks!) to remove the addtl. dot inside the number.

Thanks both, for your help!!

@Sinus - addtl. hint from my side:
PS: this is how my step looks now:  {Application.Variables.PictInFolderCount|cast:int;replace:.==}
It directly replaces the dot in the casted integer with the replace function. The .== means in fact 'make the . equal to <nothing>', because after the == there is no further character given.


blinkystar

#4
Ok, another issue now: the numbers <999 will not have leading zeros - which is important for the correct order of images.

Thus, you have to add the  ;numformat:int,04 at the end (-> @Mario, it works!  ;D - If I would have read correctly, I'ld have seen it in your comment :-\).


sinus

Quote from: blinkystar on January 07, 2016, 10:05:22 PM
@Sinus - addtl. hint from my side:
PS: this is how my step looks now:  {Application.Variables.PictInFolderCount|cast:int;replace:.==}
It directly replaces the dot in the casted integer with the replace function. The .== means in fact 'make the . equal to <nothing>', because after the == there is no further character given.

Thanks for yor hint, blinkystar.
Cool! In fact I knew this, because I uses a lot of variables for the file window... but was too lazy to change it here.

Fine, that you worked it out.
Best wishes from Switzerland! :-)
Markus