Jump to content

extract text string and paste into other field


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

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 )

)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

This topic is 5768 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
 Share

×
×
  • Create New...

Important Information

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