5 Replies Latest reply on Jan 21, 2016 7:29 PM by user19752

# How to calculate a filename

Hi,

I have a bunch of filenames that are in a URL. (for instance http://www.midline.com/media/hme/img/product/G07890TB.jpg) I need to calculate the file name by stripping everything to the left of the last forward slash. The URLs vary in length and so do the filenames, so I cannot use a fixed number of letters to remove. I know some of you Filemaker wizards will think this is simple, but I can't figure it out. Thanks for any help.

• ###### 1. Re: How to calculate a filename

Right (

urlField

; length ( urlField )

- position ( urlField ; "/" ; 1 ; patterncount ( urlField ; "/" ) )

)

HTH

Chris Cain

Extensitech

• ###### 2. Re: How to calculate a filename

Let ([

Ls = Substitute(urlField;"/";¶);

Ln = ValueCount(Ls)];

GetValue(Ls; Ln)

)

• ###### 3. Re: How to calculate a filename

I usually use the same formula as siplus,but I like pattern count usage in Chris' formula. If I did it this way I would normally use:

Right (

urlField

; length ( urlField )

- position ( urlField ; "/" ; length ( urlField ) ; -1)

)

• ###### 4. Re: How to calculate a filename

Yes, this is a known, but often forgotten, feature of Position() function. Using the length as the "start" and counting back, gives you the match from the Right side of the tested text.

-2 would give you the 2nd (from the right)

-3 would give you the 3rd (from the right)

...

beverly

• ###### 5. Re: How to calculate a filename

So I add straightforward one that "stripping everything to the left of the last forward slash"

Replace ( urlField ; 1 ; Position ( urlField ; "/" ; Length ( urlField ) ; -1 ) ; "" )

I like siplus', there is not Length()