Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6934 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

I'm trying to manage a file of media assets. What I'd like to set up (and can't figure out) is a field that will automatically fill, based on the file extension of a file that is batch imported (Import:Folder). So that when I pull in a new batch of images/files, I will have the full filename in one field and then somehow trim or query that filename and fill a second field with just the file extension of that file.

Hope that makes sense. Basically I'd like one field with "file.ext" for the name and another that would just show me "ext" as the extension of that file.

Thanks.

{edit} - just to be clear, the file names are obviously going to vary greatly, so what I'd like to figure out is how to just copy the last three characters from the filename field - as opposed to somehow trimming "X" number of characters from the start of the text. thanks

Edited by Guest
Posted

Hi

assuming that "Picture" is the name of your container field, try this calc for the picture extension:

RightWords ( Substitute (RightWords ( GetAsText ( Picture ) ; 1 ) ; "." ; " " ) ; 1 )

this calc will work either with stored images, either with referenced ones.

For the picture name try this other:

Middle ( GetAsText ( Picture ) ; Position ( GetAsText ( Picture ) ; "/" ; Length ( GetAsText ( Picture ) ) ; - 1 ) + 1 ; Length ( GetAsText ( Picture ) ) )

Posted

Custom Function

ddsExtension




/*

David Singleton

10/5/05

To Return the extension of the File, if one exists.



*/



Let([

a = Middle ( file_name ; Position ( file_name ; "." ; 1 ; PatternCount ( file_name ; "." )); Length ( file_name ) );

b = PatternCount( file_name ; ".")];



If ( b = 0; ""; a))



there are things you must account for:

1. what if the filename has extra .'s in it: file.name.exentsion, f.i.l.e.n.ame.ext

2. What if the extension is longer than 3 characters, what if its 4, or 14?

3. What if there is no extension? (Which is VERY common on the MAC side)

The function above will get you the extension, if there is one, no matter what(Or i haven't evern not gotten it back).

Being as how your on a MAC, you might want to look into looking at the Creator and filetype also. But I guess it depends on how vigilant you want to be.

Posted

Hi Zero Tolerence

i'm assuming you are responding to comment, otherwise do some better trying to my calc ( remember that the picture is Stored or Referenced in a container field)

Posted

I will have the full filename in one field...

...so what I'd like to figure out is how to just copy the last three characters from the filename field

He has the file name, there is no reason to reference the container field.

But, your first function works fine for getting the extension also.

Posted

Thank you all. I will give these all a try. For the quick fix, the "Right (filename;3)" works for me - thankfully I have control over the files I'm dealing - but having the reference for more complex situations is great - I really appreciate the suggestions and help.

Posted

If you do have files with a longer extension or no extension at all, try:

Let ( [

len = Length ( FileName ) ;

dot = Position ( FileName ; "." ; len ; -1 )

] ;

Case ( dot ; Middle ( FileName ; dot + 1 ; len - dot ) )

)

This topic is 6934 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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