December 12, 200619 yr 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!
December 12, 200619 yr 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
December 12, 200619 yr Or: Let ( [ start = Position ( text ; "/" ; 1 ; 3 ) + 1 ; end = Position ( text ; "/" ; 1 ; 4 ) ] ; Middle ( text ; start ; end - start ) )
December 12, 200619 yr You see, i thought about that, but what if there's another sub folder between File://c:/ and /templates?
December 12, 200619 yr Author Great - thanks for these - I'll try them out now. And yes, there are occasionally multiple subfolders between "C:/" and "/Thumbnails".
December 12, 200619 yr Author 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.
December 12, 200619 yr 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.
December 12, 200619 yr 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 ) )
December 12, 200619 yr Author 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 December 12, 200619 yr by Guest
Create an account or sign in to comment