Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

extracting file name

Featured Replies

I have a simple script to insert pictures into a container field. Is there a way to extract the picture file name for pasting into a text field.

If you are inserting pictures NOT as a reference then a simple Set Field step will do the trick:

Set Field [MYTABLE::Name; MYTABLE::Container]

Make sure the Path field is a text field and FileMaker will automatically convert the picture to the original file name.

If you are storing your pictures as references, you will need a more complex formula in order to extract just the file name. The same Set Field shown above would result in the size as well as several paths. All you need is the very last value so this simple formula in the Set Field calculated result option will work:

RightValues(Substitute(MYTABLE::Name; "/"; "¶"); 1)

This formula replaces all of the "/" in the path with return characters so you can easily grab the last value using the RightValues function.

...RightValues(Substitute(MYTABLE::Name; "/"; "¶"); 1)

This formula replaces all of the "/" in the path with return characters so you can easily grab the last value using the RightValues function.

Worth bearing in mind, though, that the RightValues( ) function, like all of the xxxValues( ) suite of functions, returns a result which has a trailing carriage return.

That may or may not be a problem for you, depending on what you intend to do with the file name once you have it in the field. However if it is likely to present a problem, you could remove it in any of various ways, one of which would be:

Let([

x = Substitute(MYTABLE::Name; "/"; "¶");

y = RightValues(x; 1)];

Left(y; Length(y) - 1)

)

- or another would be to enclose the original formula within a further Substitute( ) function, to replace ¶ with "". etc etc :)

Yes, I forgot that. Thanks.

You could also use the following formula to remove the trailing return:

LeftWords(RightValues(Substitute(MYTABLE::Name; "/"; "¶"); 1); 999999999)

You could also use the following formula to remove the trailing return:

LeftWords(RightValues(Substitute(MYTABLE::Name; "/"; "¶"); 1); 999999999)

Hi John,

It may not be a problem if the picture files will follow known naming conventions (and given they will have extensions from a fairly predictable subset), but there is a caveat to keep in mind when using one of the xWords( ) functions in this way.

The xWords( ) functions not only strip leading and trailing carriage returns but in addition, will strip off leading and trailing spaces, periods, punctuation marks and any combination thereof.

So in the case of file names, if you store a file with the name "__ * 0123.png", using LeftWords( ) in this way will return only "0123.png" or for a file called "• (0251)_block.C++", it will return only "1251) _block.C".

Like you, I've used the xWords( ) functions in this way sometimes, but have found that it pays to be mindful of this particular limitation. :)

Hi John,

It may not be a problem if the picture files will follow known naming conventions (and given they will have extensions from a fairly predictable subset), but there is a caveat to keep in mind when using one of the xWords( ) functions in this way.

The xWords( ) functions not only strip leading and trailing carriage returns but in addition, will strip off leading and trailing spaces, periods, punctuation marks and any combination thereof.

So in the case of file names, if you store a file with the name "__ * 0123.png", using LeftWords( ) in this way will return only "0123.png" or for a file called "• (0251)_block.C++", it will return only "1251) _block.C".

Like you, I've used the xWords( ) functions in this way sometimes, but have found that it pays to be mindful of this particular limitation. :

I agree and should have mentioned it in my post. Thanks.

This my or may not belong here, but following your discussion of the xWords() functions... I was surprised today to find that the functions behave somewhat differently depening on what precedes the . (dot).

I was using RightWords() to check the extension of a file and found that my calc failed. Of course now I know to use a different method...

I was checking the name of a file in a container field "object" to see if it was of the pdf type.

RightWords(GetAsText( object ); 1)

returns "pdf" when the file is anything123.pdf but it returns "anything.pdf" when it has no numbers preceding the dot.

I thought it strange. I am open for thoughts on why this woud be.

Thanks, Comment. Good references.

  • Author

Thank you for the help. No lack of detail with this bunch. Cheers.

  • 2 months later...
  • Newbies

If you are inserting pictures NOT as a reference then a simple Set Field step will do the trick:

Set Field [MYTABLE::Name; MYTABLE::Container]

Make sure the Path field is a text field and FileMaker will automatically convert the picture to the original file name.

Can't get this to work--I'm getting a ?. Tried as a script step, calculated text field, and text field with a default calculation. Can someone help?

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.