mixtus Posted May 26, 2004 Posted May 26, 2004 i have two fields field 1 = image ( this is a container that holds a jpg ) field 2 = imagename ( this is a field that holders the name of the image ) when i insert an image into field 1 i would like it to automatically add the file name into field 2. is this possible? i tried to mess around with Get(fileName) - but i am super new with FMP thanks mix
Reed Posted May 26, 2004 Posted May 26, 2004 Use the File:Import Records:Folder... command. This will allow you to specify filenames, etc. when importing images, movies or other media files.
mixtus Posted May 27, 2004 Author Posted May 27, 2004 that doesn't work for me because i already have the records in the database. that would be great if i was starting the database from scratch. I want to be able to go through the database that i have set up and drop the images in and then get the file name to go into another field. Exactly what i said in my first post. Does anyone know how to do this. I am sure there is an easy way. thanks, mix
mixtus Posted May 31, 2004 Author Posted May 31, 2004 i guess not many people visit this forum. please i need help. seems like a simple problem. is there a more popular forum for fmp?
H.P. Posted May 31, 2004 Posted May 31, 2004 I don't know if there's a way to do it quickly but you could try to work around by writing a script to export the field content to a dir, then import it in again w/.
Fenton Posted May 31, 2004 Posted May 31, 2004 You do not say what platform you're on. On a Mac you can use AppleScript to get this info, if the image was inserted as a reference only. On a PC I believe the ImageScan plug-in can get do it. If it is embedded, not as a reference, I don't believe there is any way to get the "name," because it no longer has a file name. It's just a picture in a container field; like a picture on the clipboard, the picture's there, but it has no name. If you're on a Mac, look at this thread: http://www.fmforums.com/threads/showflat.php/Cat/0/Number/105161/Main/105161
The Shadow Posted May 31, 2004 Posted May 31, 2004 In FM7, AppleScript isn't required, if the file is a reference: GetAsText(container) will provide all info about it. This could be helpful if you're using Windows, as their AppleScript support sucks.
Fenton Posted May 31, 2004 Posted May 31, 2004 Sorry, didn't catch the FileMaker 7 in the profile of mixtus' first post.
mixtus Posted June 1, 2004 Author Posted June 1, 2004 ok i used GetAsText(container) that works but it gives me this...... " size:75,75 image:client_images/quick.jpg imagemac:/Macintosh HD/Users/me/Desktop/client_images/quick.jpg " this is really cool but all i want is the name quick.jpg is there a way to do it without using apple script. I am on osx // but it seems like something that could be solved in fmp7 thank you all for responding // I am evaluating the trial version of fmp7 and this is something that will help me decide if i want to use it.
The Shadow Posted June 1, 2004 Posted June 1, 2004 The calculation: RightWords( MiddleValues( GetAsText(container); 2; 1 ); 1 ) will pick out just the filename.
Fenton Posted June 1, 2004 Posted June 1, 2004 If the container field is named "Image": Right ( GetAsText(Image); Length ( GetAsText(Image) ) - Position ( GetAsText(Image) ; "/" ; 1 ; PatternCount ( GetAsText(Image); "/" ) ) )
The Shadow Posted June 1, 2004 Posted June 1, 2004 One more thing, I just noticed... the calculation: Length(container) returns: - empty, if the container is empty - 0, if its a reference - the image's size (in bytes?) if its stored internally. So that also provides an easy way to tell when asking for the filename isn't going to work, since they image is stored inside the database.
jfmcel Posted June 1, 2004 Posted June 1, 2004 If you decide to go with a < 7 version, here is an applescript that will give you the file name and a few other bits of info. Of course, you'll need to adjust the field names... tell application "FileMaker Pro" try set TheImage to cell "Container" of current record on error errMes set cell "File Path" of current record to errMes end try try set cell "File Path" of current record to TheImage as text on error set cell "File Path" of current record to "Image not stored as a reference" set cell "File Size" of current record to "" set cell "File Type" of current record to "" return end try end tell set FileInfo to (info for TheImage) set theSize to (size of FileInfo) / 1048.567 tell application "FileMaker Pro" set cell "File Name" of current record to name of FileInfo set cell "File Type" of current record to file type of FileInfo if theSize > 1000 then set cell "File Size" of current record to ((((round (theSize / 10)) / 100)) as string & " MB") as string else set cell "File Size" of current record to ((round (theSize)) & " K") as string end if end tell
mixtus Posted June 2, 2004 Author Posted June 2, 2004 shadow - thank you ---- thank you. RightWords( MiddleValues( GetAsText(container); 2; 1 ); 1 ) very very
The Shadow Posted June 2, 2004 Posted June 2, 2004 mixtus, There's an "Execute SQL" script step that can talk to an ODBC data source. I've never actually tried it, but that seems like it should do the trick.
mixtus Posted June 2, 2004 Author Posted June 2, 2004 i have been using RightWords( MiddleValues( GetAsText(image); 2; 1 ); 1 ) it seems that it is working sometimes yes - sometimes no. sometimes if i import an image like "image08.jpg" all i get is "jpg". other times it works correctly. i am not sure why this is happening. any ideas?
The Shadow Posted June 3, 2004 Posted June 3, 2004 Bother, the word break rule for "." - it is considered NOT to be a word break when between letters ("fm.com") or numbers (3.4), but it is when they're mixed. Try this instead: Let( imgName = RightWords( MiddleValues( GetAsText(con); 2; 1 ); 1 ); If ( Position( imgName; "."; 1; 1 ); imgName; RightWords( MiddleValues( GetAsText(con); 2; 1 ); 2 ) ) )
mixtus Posted June 3, 2004 Author Posted June 3, 2004 hey shadow, that works great- thanks for taking the time to write that. is there any resources out there for learning how to write these scripts. I am pretty good at actionscripting and php, so i think i could pick it up. thanks again -mix
elvis_impersonating_penguin Posted June 3, 2004 Posted June 3, 2004 ok... so i take it, short of a plugin, there is no way to grab the filename in FM6 on a PC?!?!? I got around checking the "store only a reference to the file", but i need to find a way to get the filename of the file... i mean, it has to be stored somewhere.. lol
The Shadow Posted June 4, 2004 Posted June 4, 2004 Well, the FileMaker help is okay, and explains what all the functions do. I'm not really sure where I picked up my "how-to" knowledge anymore, since that was a while ago... I think "Scriptology" is supposed to be pretty good, but I would wait until the FM7 version is released to buy it. Perhaps others might have some better ideas.
Leb i Sol Posted June 7, 2004 Posted June 7, 2004 it is a bit "OT" but it could be of some use: http://www.fmforums.com/threads/showflat.php/Cat/0/Number/109002/page/0/view/collapsed/sb/5/o/all/fpart/1 take care!
Scott Quiring Posted June 17, 2004 Posted June 17, 2004 Not if the file name contains a space or other word separator. I suggest: RightValues(Substitute(MiddleValues(GetAsText(container); 2; 1); "/"; "[par]"); 1) "[par]" should be the paragraph caracter . I guess it doesn't work within quotes (which seems silly because that's the only place it should be)
The Shadow Posted June 17, 2004 Posted June 17, 2004 BTW, FM7 no longer requires the quotes for a single paragraph mark. True and False now exist as named constants also.
Leb i Sol Posted June 17, 2004 Posted June 17, 2004 if u stick into a "quote"it will work RightValues(Substitute(MiddleValues(GetAsText(container); 2; 1); "/"; " "); 1) Good Call on filenames and spaces....but for "reference security" I make my users imageName = unique,ItemID or something. that way u have eg: ImageName | ItemID -------------------- ABC.jpg | ABC vs. my house.jpg | ABC this iway I can also estimate the name of the image_file.jpg and compund it...warn users that they have not "Uploaded/added" the "right" image. Anyhow, thanx for more input! Take care
Kip Posted August 13, 2004 Posted August 13, 2004 This GetAsText function sounds really useful. Would it be possible to use GetAsText if the file that is put in the containerfield is not a picture but something else, let's say un unknown file type?
Fenton Posted August 13, 2004 Posted August 13, 2004 Yep. It will return the paths for any file inserted, if it's inserted as a reference (which kind of makes sense, 'cause it has to store the paths to know where it is). But not for totally embedded files.
apwalton Posted August 30, 2004 Posted August 30, 2004 This is just what I needed, but it is cutting the file name short at an underscore character. Any advice on how to accomodate that? Bother, the word break rule for "." - it is considered NOT to be a word break when between letters ("fm.com") or numbers (3.4), but it is when they're mixed. Try this instead: Let( imgName = RightWords( MiddleValues( GetAsText(con); 2; 1 ); 1 ); If ( Position( imgName; "."; 1; 1 ); imgName; RightWords( MiddleValues( GetAsText(con); 2; 1 ); 2 ) ) )
Fenton Posted August 30, 2004 Posted August 30, 2004 I would not use RightWords. Try this: Let ( info = GetAsText(PictAsRef); Right ( info; Length(info) - Position ( info ; "/" ; 1 ; PatternCount(info; "/") )) )
remixculture Posted September 7, 2004 Posted September 7, 2004 I have a different but similar inquiry... I am running FMPro7 on XP. I have a database that we have the images. Instead of saving all the images (DOH!)I have ~ 1500 images embedded as images in container fields. Now I can copy and paste into like Fireworks or something no problem. I am trying to export all the images... export them both as text (eg. productimage01.jpg) and to have Filemaker save the corresponding image file and in a certain specified folder (eg. images/productimage01.jpg). HELP PLEASE
remixculture Posted September 8, 2004 Posted September 8, 2004 Fenton & Shadow- I see this thing you made... I have a similar need. My Field name is Image Large... So, please, forgive me... but is this what we do... 1) Define a new field called save... 'imagename' 2) Set 'imagename' field to CALCULATION 3) define the calculation as: Right ( GetAsText(Image Large); Length ( GetAsText(Image Large) ) - Position ( GetAsText(Image Large) ; "/" ; 1 ; PatternCount ( GetAsText(Image Large); "/" ) ) ) And then Close... add field to my layout... and let it do it's thing??? That is what I did.. and I just get a '?' If the container field is named "Image": Right ( GetAsText(Image); Length ( GetAsText(Image) ) - Position ( GetAsText(Image) ; "/" ; 1 ; PatternCount ( GetAsText(Image); "/" ) ) )
remixculture Posted September 8, 2004 Posted September 8, 2004 i also tried 'Image' for field and still it doesn't work... ack
Fenton Posted September 8, 2004 Posted September 8, 2004 The calculation only gets the "name" for an image which as been inserted "as a reference only." Such an image is still a file on the disk, hence has a name. A completed embedded image is just that, an image, no file on disk, hence no name, hence "?" is all you get. Possibly Troi File plug-in can do this. I know ImageScan can: http://www.powersolutions.it/en/insidescan.html I haven't used it however, because on a Mac we can do with AppleScript (not that it's something you'd want to do often).
remixculture Posted September 8, 2004 Posted September 8, 2004 ah... so that stuff is MAC... ok... thanks... I'll give that Troi and ImageScan stuff a look... I have FMP7 on a MAC too... would it simply work if I opened this XP file in there do you think? and if it were to... would I use that stuff as a calculation : respects- eric
remixculture Posted September 8, 2004 Posted September 8, 2004 omg... the manual for ImageScan is 116 pages... I didn't realize this can be such a difficult task...
Recommended Posts
This topic is 7476 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 accountSign in
Already have an account? Sign in here.
Sign In Now