Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hi, I need to extract a bit of text from a field and move it into another field.

Here's what I've got. My field "Source" contains a long file name for the image which I have imported into that record. I would like to copy part of this file name and paste it into a field called "Album Name".

The contents of the Source field look like this:

file://C:/British Aviation Sqn Markings/Thumbnails/05 - BE2e - test aircraft - camouflage.tif

I would like to take the text between "C:/" and "/Thumbnails" and copy it to the Album Name field.

All help and suggestions appreciated!

Posted

Set Field[ TableName::Album Name ;

Let( [ source = TableName::SourceField ;

rawpath = Position( source ; "/" ; 1 ; 3 ) + 1 ;

rightLength = Position( source ; "/Thumbnails" ; 1 ; 1 ) + Length ("/Thumbnails") + 1 ];

Middle( source ; rawPath ; Length(source) - rawpath - rightlength )

)

should work

Posted

Or:

Let ( [

start = Position ( text ; "/" ; 1 ; 3 ) + 1 ;

end = Position ( text ; "/" ; 1 ; 4 )

] ;

Middle ( text ; start ; end - start )

)

Posted

You see, i thought about that, but what if there's another sub folder between File://c:/ and /templates?

Posted

Great - thanks for these - I'll try them out now.

And yes, there are occasionally multiple subfolders between "C:/" and "/Thumbnails".

Posted

ok, newbie alert -

I'm just using Filemaker Pro, not Developer. Am I able to use this script in Pro? And if so, do I paste it into the "Specify Calculation" dialog box for the Set Field command? I've been trying to do it this way, but always get a message to insert an operator after the first line.

Thanks again! Sorry for my newbishness.

Posted

Yeh...

Just Go into ScriptMaker, Make a new script, choose set field, choose your destination field (album name).

Next, choose specify calc

Let( [ source = [color:blue]TableName::SourceField ;

rawpath = Position( source ; "/" ; 1 ; 3 ) + 1 ;

rightLength = Position( source ; "/Thumbnails/" ; 1 ; 1 ) + Length ("/Thumbnails/") + 1 ];

Middle( source ; rawPath ; Length(source) - rawpath - rightlength )

)

Replace the blue bit with your source field.

Posted

Come to think of it, if Thumbnails is always the folder before the file, you could use a slightly modified version of LaRetta's calc below. (text is just your source field)

Let ( [

start = Position ( text ; "/" ; 1 ; 3 ) + 1 ;

end = Position ( text ; "/" ; 1 ; PatternCount( text ; "/" ) - 1 )

] ;

Middle ( text ; start ; end - start )

)

Posted (edited)

Ok, I'm definitely getting there. At this point it's copying various string lengths into the Album Name field - sometimes it's the first word, sometimes it's all the way through "Thumbnails"

example:

British Aviation Sqn Markings/Th

or

British Aviation Sqn Markings/T

or

British Aviation Sqn Markings/Thumbnails/09 - RE8

"Thumbnails" will always be the folder AFTER the file name that I want, btw.

Thanks so much!!!

Edited by Guest

This topic is 6558 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.