Jump to content
Salesforce and other SMB Solutions are coming soon. ×

automating 'insert picture' - large number of images


aregan

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.... :-(

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 years later...
This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

Terms of Use