If the file name is always numeric you could use:
Filter ( FileName ; "1234567890" )
If you can rely on there being only "." in the name you can use
"0213906" for a file named "0213906.jpg"
"my filename" for a file named "myfilename.jpg"
"theName" for a file named "theName" (note that this one didn't have an extension originally)
If you want to handle files like "You are great. I am fine .jpg" and get ""You are great. I am fine " as the result, then you need something a little more sophisticated.
theFileNameList = Substitute(FileName;".";"¶");
theLeftFileNameList = LeftValues(theFileNameList; ValueCount(theFileNameList)-1);
theLeftFileName = Substitute(Left(theLeftFileNameList; Length(theLeftFileNameList) - 1); "¶"; ".")
PatternCount(FileName; ".") < 1;FileName;
A couple of simple alternative methods:
Substitute(FileName; ".jpg"; "") Replaces the string .jpg with nothing.
Left(FileName; Length(FileName) - 4) Strips the last four characters off the contents of the FileName field.
I suppose I'd got for something pretty straightforward, to remove all text in front of the last period:
Let ( [
text= "this_is _a-strange.filename.jpg" // or your field name goes here
; searchString= "."
; position= Position ( text ; searchString ; Length ( text ) ; -1 ) // find the first period starting from the right
; result= Case ( position > 0 ; Left ( text ; position - 1 ) ; text ) // get the left portion of the text
) // end Let
Trim() can't really help here, it only deals with spaces.
If you do need to trim other white space characters from the beginning and end of a string, use Debi Fuchs brilliant (non-recursive) SuperTrim() custom function. http://www.briandunning.com/cf/904
-- Drew Tenenholz
>I've imported 3,000 odd images which are name with a site number ie: 0213906.jpg and I need to created a new calculated field that only display the text "0213906" ie without the extension.
>I need this to link to a table of data relating to this site number.
>Note: the field is called: FileName and I think I should be using the trim function but I couldn't get it to work correctly.
Thanks to everyone for the great solutions.
I am switching form Access to Filemaker and the functions are a little different.