Variable processing with substr and replace

Started by axel.hennig, May 07, 2023, 10:19:51 PM

Previous topic - Next topic

axel.hennig

Hello,

I've got a question regarding processing variable.

Let's assume I've got a file with the name 2018_Wedding_123456.jpg and the 123456 is the OID.

I would like to display the filename without the OID, i.e. without the 123456. Therefore, I was thinking of using the substr function. I've started with

{File.Name|length} -> 19
{File.Name|substr:0,19} -> 2018_Wedding_123456
Then I've tried:

{File.Name|substr:0,{File.Name|length}} -> EMPTY
I don't understand why that does not seem to work.

I came to a solution by doing:

{File.Name|replace:{File.OID}==}
As I said I found a solution, but still don't understand why my first try does not work.

Mario

For the file name COPY.NEF,

{File.Name|length}

returns 4 and

{File.Name|substr:0,{File.Name|length}}

returns

COPY

in VarToy.
Seems to work just fine.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Mario, I also tried your example. But for me, {File.Name|length} returns 4 as expected, but {File.Name|substr:0,{File.Name|length}} returns an empty string. (Same result as Axel gets).
Maybe something that only works on the newer code base you are using?
Thorsten
Win 10 / 64, IMatch 2018, IMA

sinus

Yep, like Thorsten and Axel, the result-line is empty, I get in VarToy:

filename: {File.Name}
filename length: {File.Name|length}
filename substr: {File.Name|substr:0,4}

one } at the end deleted: {File.Name|substr:0,{File.Name|length}
empty: {File.Name|substr:0,{File.Name|length}}

results:
filename: copy
filename length: 4
filename substr: copy

one } at the end deleted: {File.Name|substr:0,4
empty:


Best wishes from Switzerland! :-)
Markus

Mario

Quote from: thrinn on May 08, 2023, 08:24:12 AMMario, I also tried your example. But for me, {File.Name|length} returns 4 as expected, but {File.Name|substr:0,{File.Name|length}} returns an empty string. (Same result as Axel gets).
Maybe something that only works on the newer code base you are using?
This is very possible.
I've reworked quite some things in variables for IMatch 2023.
I get

{File.Name}
{File.Name|length}
{File.Name|substr:0,{File.Name|length}}
{File.Name|substr:5,{File.Name|length}}

_DSC-1234567890
15
_DSC-1234567890
1234567890[/font][/size][/color][/pre]

Probably the embedded variable parameter length was not processed and evaluated in older versions o the substr function.
It works now, though.

Doing a replace works just as fine in IMatch 2021.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

axel.hennig

Thanks Thorsten and Markus for checking.