aregan Posted May 28, 2008 Share Posted May 28, 2008 I want to ‘insert picture’ into several thousand records (Filemaker 8, flat file) and I don’t want to do it one at a time! How can I do this? Each image in my folder of images has a name (eg. 05827.jpg) that corresponds to its record number in my database. I have a container field in each database record into which I want to save a reference to the image. I can do this one record at a time, but surely there is a way to automate it. Many thanks for help, Anita Quote Link to comment Share on other sites More sharing options...
Maarten Witberg Posted May 28, 2008 Share Posted May 28, 2008 Is that an unbroken sequence of image numbers? so 1-3000 without gaps? Quote Link to comment Share on other sites More sharing options...
aregan Posted May 28, 2008 Author Share Posted May 28, 2008 no, it's not an unbroken sequence. I can 'find' all the records that I want to put images in, and their numbers should be in the same order as the correspondingly numbered images in my other folder. Quote Link to comment Share on other sites More sharing options...
Maarten Witberg Posted May 28, 2008 Share Posted May 28, 2008 ok for maximum clarity. you have record numbers with unique serials that are numbered 00001, 00002, 00003,..... etc. but sometimes it might be ....00450, 00451, 00470, 00480, 00481, ..... and you have image files with matching numbers? I can take a stab at writing a script for this. but I want to make sure I understand things right. ps edit : ooo... I just notice you're using v8. me and my big mouth. do you have script variables in version 8? I have 6, 7, 8.5 and 9....not 8.0 so I can't check.... Quote Link to comment Share on other sites More sharing options...
aregan Posted May 29, 2008 Author Share Posted May 29, 2008 Yes, you've described the situation exactly. ok for maximum clarity. you have record numbers with unique serials that are numbered 00001, 00002, 00003,..... etc. but sometimes it might be ....00450, 00451, 00470, 00480, 00481, ..... and you have image files with matching numbers? I can take a stab at writing a script for this. but I want to make sure I understand things right. do you have script variables in version 8?.... I am running 8.0 v3, and I don't know what a 'script variable' is smiley-cry , but I will find out. AR PS Is this what a plug-in called Grab-it will do? I just remembered someone here mentioned that to me? I will do more research on that too. Quote Link to comment Share on other sites More sharing options...
aregan Posted May 29, 2008 Author Share Posted May 29, 2008 Yes, you've described the situation exactly. I am running 8.0 v3, and I don't know what a 'script variable' is smiley-cry , but I will find out. AR PS Is this what a plug-in called Grab-it will do? I just remembered someone here mentioned that to me? I will do more research on that too. Ok, I've looked at Grabit, and it's cheap. - I'll get it. Many, many thanks for your help. (and 8 does allow script variables) AR Quote Link to comment Share on other sites More sharing options...
Maarten Witberg Posted May 29, 2008 Share Posted May 29, 2008 Based on your description, a script like this could do the trick: Set error capture [on] Go to record / request [ first ] Loop Set Variable [ $path ; value: Substitute ( LeftWords ( Get ( filepath ) ; WordCount (Get ( Bestandspad ) ) - 1 ) & "/" & table::serial & ".jpg" ; "file:" ; "imagemac:" ) ] Go To Field [ table::ImageContainer ] Insert Picture [ reference only ; $path ] If [ get ( lasterror ) // no file found ] show custom dialog [ "file not found" ; "file missing: " & $path ] # more error handlig here End if Go to record / request [ next ; exit after last ] End loop I used the Get (Filepath) status function to determine the file path, this works if you put your solution into the same folder as the images. Otherwise hardcode the filepath excluding the filename. Quote Link to comment Share on other sites More sharing options...
aregan Posted June 2, 2008 Author Share Posted June 2, 2008 It is really generous of you to write this. After I get it set up, I'll let you know if I can get it to work! Thanks, Anita Quote Link to comment Share on other sites More sharing options...
sujat Posted June 2, 2008 Share Posted June 2, 2008 Hi kjoe, I was trying your script for inserting images. What is the meaning of Get ( Bestandspad ) in the code below ?smiley-frown Set Variable [ $path ; value: Substitute ( LeftWords ( Get ( filepath ) ; WordCount (Get ( Bestandspad ) ) - 1 ) & "/" & table::serial & ".jpg" ; "file:" ; "imagemac:" ) ] Thanks Sujat Quote Link to comment Share on other sites More sharing options...
Maarten Witberg Posted June 2, 2008 Share Posted June 2, 2008 sorry. that's dutch.... try get ( filepath ) on a side note, I have succeeded in creating a script that imports all images in a folder regardless of their filenames (so that's quite different from the above). However I needed to write an applescript to grab all filenames. Do you happen to know VBscript to pull of something like that in windows? Quote Link to comment Share on other sites More sharing options...
Maarten Witberg Posted June 2, 2008 Share Posted June 2, 2008 fwiw, this is the applescript in question. tell application "Finder" set selectedFolder to choose folder with prompt ¬ "Choose folder." set filelist to (name of every file of entire contents of selectedFolder) as list end tell tell application "FileMaker Pro Advanced" activate set data of cell "ImportUtility::gList" to filelist set data of cell "ImportUtility::gPath" to selectedFolder as string end tell you can use this as a native applescript in a filemaker script which then proeeds by looping through gList, using gPath to concatenate the import paths. It's pretty quick, at least standalone. but I'm not xplat.... :-( Quote Link to comment Share on other sites More sharing options...
sujat Posted June 2, 2008 Share Posted June 2, 2008 I don't know anything about VBscript. Sorry Quote Link to comment Share on other sites More sharing options...
sujat Posted June 2, 2008 Share Posted June 2, 2008 Tried your method. Here is the script - Set Error Capture [ On ] Go to Record/Request/Page [ First ] Loop Set Variable [ $path; Value:Substitute ( LeftWords ( Get ( FilePath ) ; WordCount (Get ( FilePath ) ) - 1 ) & "/" & Students::Roll No & ". jpg" ; "file:" ; "imagemac:" ) ] Go to Field [ Students::Image Data ] Insert Picture [ “$path†] [ Reference ] If [ Get ( LastError ) // no file found ] Show Custom Dialog [ Title: "Alert"; Message: "No image found"; Buttons: “OKâ€, “Cancel†] End If Go to Record/Request/Page [ Next; Exit after last ] End Loop It is showing the Custom dialog " No image found" I have the FMP file in the same folder as the images. The images are numbered 1,2 ,....12 The Roll no field has serial no. 1,2,.....15 Is there a mistake somewhere ? Thanks. Sujat Quote Link to comment Share on other sites More sharing options...
Maarten Witberg Posted June 2, 2008 Share Posted June 2, 2008 Set Variable [ $path; Value:Substitute ( LeftWords ( Get ( FilePath ) ; WordCount (Get ( FilePath ) ) - 1 ) & "/" & Students::Roll No & ".jpg" ; "file:" ; "imagemac:" ) ] should be Set Variable [ $path; Value:Substitute ( LeftWords ( Get ( FilePath ) ; WordCount (Get ( FilePath ) ) - 1 ) & "/" & Students::Roll No & ". jpg" ; "file:" ; "imagewin:" ) ] you should check to see what get (filepath ) returns on your box and then adapt the parse if necessary. I'm not sure about the "file:" bit either. its another one of those mac/win things. Quote Link to comment Share on other sites More sharing options...
sujat Posted June 3, 2008 Share Posted June 3, 2008 kjoe, File path is showing as - file:/C:/Documents and Settings/sujat/Desktop/Image/Student Fees 2 Change 4.fp7 My file and images are there in Image folder . I changed "imagemac:" to "imagewin:" but it is showing custom dialog " no image showing". One more thing, when I select one image in Insert Picture script line it is inserting that perticular image in all the records. Quote Link to comment Share on other sites More sharing options...
sujat Posted June 3, 2008 Share Posted June 3, 2008 Going through FMP Help under " Importing a folder of files all at once " I found that files ( Text , Image & Movie ) can be imported from a folder into FMP file. I changed insert picture to Import folder. Set Error Capture [ On ] Go to Record/Request/Page [ First ] Loop Set Variable [ $path; Value:Substitute ( LeftWords ( Get ( FilePath ) ; WordCount (Get ( FilePath ) ) - 1 ) & "/" & Students::Roll No & ". jpg" ; "file:" ; "imagewin:" ) ] Go to Field [ Students::Image Data ] Import Records [ Folder Name: ./; Include all enclosed folders; File Type: Picture and movie files; Target: “Studentsâ€; Method: Update matching; Character Set: “Windows ANSIâ€; Field Mapping: Source field 1 import to Students::Image Data Source field 2 match with Students::Roll No Source field 3 import to Students::Getpath ] [ No dialog; Data contains column names ] If [ Get ( LastError ) // no file found ] Show Custom Dialog [ Title: "Alert"; Message: "No image found"; Buttons: “OKâ€, “Cancel†] End If Go to Record/Request/Page [ Next; Exit after last ] End Loop I created a field > Getpath and it is showing as file://C:/Documents and Settings/sujat/Desktop/Image/1.jpg file://C:/Documents and Settings/sujat/Desktop/Image/2.jpg ... etc. It is working nicely.But showing custom dialog "No image found". When the Image field is empty it appearing once and the dialog goes away whether I click "OK " or " Cancel ". But when a few records have image is appearing for each record. It will be great if that can be sorted out. Thanks Sujat Quote Link to comment Share on other sites More sharing options...
TManship Posted March 4, 2011 Share Posted March 4, 2011 Hi Anita; Are you still located in Halifax? I'm in Truro and I was wondering if I could email you? Thanks Tammi (tammi@tnlp.ca) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.