1 of 1 people found this helpful
The following calculation will extract the complete file name from any container field regardless of storage options and insertion method except for the one deprecated option mentioned:
//This should work for all insertion and storage methods except Insert Object (Filemaker 11, WIndows only):
Let ( [ T = If ( LeftWords ( YourTable::ContainerFIeld ; 1 ) = "remote" ; GetValue( YourTable::ContainerFIeld ; 1 ) ; GetValue ( YourTable::ContainerFIeld ; ValueCount ( YourTable::ContainerFIeld ) ) ) ;
L = Length ( T )];
If ( LeftWords ( T ; 1 ) = "remote" ; Right ( T ; L - 7 ) ; Right ( T ; L - Position ( T ; "/" ; L ; -1 ) ) )
So if you used this expression:
Let ( fn = put result of above calc here ;
Right ( fn ; length ( fn ) - Position ( fn ; "." ; Length ( fn ) ; -1 ) )
) // Let
You'd extract just the file extension from the file name of the inserted file.
For more on this, see: Exploring the use of a $Path Variable in Scripts
Thank you very much, I'll go for it.
I also needed to get the file extension from a file in a container field. First I got the name of the file in the container, Then I substituted periods in the name with paragraph marks (¶) and used GetValue to extract the last value, which would be the extension.
Set Variable [ $New Doc; Value:GetAsText(Table::Container)
Set Variable [ $doc type; Value:Let (name = Substitute($New Doc; "." ; ¶); GetValue(name;ValueCount(name)))]
All my container files are on a local machine so while this solution has its limits, it did work for what I needed.