Jump to content
Server Maintenance This Week. ×

Please help with batch Image export


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

Recommended Posts

I know this might be an old question however I am unable to solve it

Originally I had a FMP12 DB one table only with these fields

1 STUDENTID

2 PIC1

3 PIC2

4 PIC3

5 PIC4

6 PIC5

Everything is in the DB there are no references files.

There are about 2000 records in my file therefore the various image files are very many although not every record is fully populated. Some records have less material

I tried the standard suggestions I found googling:

Go to Record/Request/Page [First]

Loop

* Set Variable [$filePath; Value: Get ( DesktopPath ) MyPics::Description & ".jpg"]

** Export Field Contents [MyPics::Picture; “$filePath”]

Go to Record/Request/Page [Next; Exit after last]

End Loop

I tried with few images just to see if it worked

I got this error:

“<filename>” could not be created on this disk. Use a different name,make more room on the disk, unlock it or use a different disk

Not one of the reasons suggested to avoid the error in the FMP support applies to my case. The folder is empty. I am the admin, there are no weird symbols and so on.

I don't understand what goes wrong. All images are standard JPG files and the short FIlms are MOV

How can I export each image within each record giving the filename the STDENTID and a number to a folder of choice, and avoid this error?

Also in FMP12 it seems images load randomly. The very same file work perfectly in FMP11. Unfortunately I no longer have it.

Is there a way to attach the various images so instead of the running arrow I get the actual file? Maybe "committing the image to the field" with a script?

Thanks a lot from an old man

Dan

Link to comment
Share on other sites

The value for $filePath should be Get(DesktopPath) & MyPics::Description & ".jpg" . Is what you wrote above a transcription error?

Since you have FMPA, use the Data Viewer to verify that $filePath resolves to a valid path.

The folder is empty.

You haven't specified a folder. The $filePath you (almost) specified would put the file directly on the desktop (Unless MyPics::Description contains a folder reference).

If you wanted it in a folder, your script should read something like

Set Variable [$folder; Value: "MyFolder/"]

Set Variable [$filePath; Value: Get(DesktopPath) & $folder & MyPics::Description & ".jpg"]

FileMaker can't create folders; you would have to use a plugin or Applescript to create one earlier in the script.

Link to comment
Share on other sites

FileMaker can't create folders; you would have to use a plugin or Applescript to create one earlier in the script.

On Windows, no need for a plugin, a command line executed through Send Event will do just fine.

Link to comment
Share on other sites

I know this might be an old question however I am unable to solve it

Originally I had a FMP12 DB one table only with these fields

Please update your profile to reflect your current version of FileMaker, OS, and Platform. Here is a quick link Profile.

Link to comment
Share on other sites

It sounds to me like there are a lot of issues going on here...

  1. formatting of the output path, as doughemi mentioned
    If you look at the 'Export Field Contents' steps 'Specify Output File' window, it give you examples of the format it expects. On Windows, Get(DesktopPath) return a path formatted like this: '/E:/Dan/Desktop/'. So, in addition to the folder on the desktop to use, as doughemi mentioned, you need to add:

    "filewin:" & Get( DesktopPath )



  2. You said you have jpg and mov files - but you are hard-coding a ".jpg" file extension. You can use text functions to retrieve the file extension from the container field. The logic would work something like: find last ".", return all text after that, append that to your file name

  3. In your script, you are only exporting one field per record, but you said there were 5, so you will need to have 5 export field steps in the loop (one for each container image). I would recommend checking if the field is empty before attempting to export it.

  4. In your script, you are using the 'Description' field for the file name, but you said you want the file named by the STUDENTID field - so replace one field with the other, in your script. You also want each field to have an additional number appended to the file name (if I understood you correctly) so you should hard-code that in the path for each export field contents step in your loop.

  5. Why don't you have FileMaker 11 anymore? Did you recently change computers? If so, then my guess is that all the images weren't included in the database. Some of them could have been stored as a reference, and now that reference is broken. I've seen this before - where someone though all images were always included in the database, but if you never move your database to another computer then you likely would never know if they were stored as a reference or not
Link to comment
Share on other sites

Thanks everyone for helping out. I now successfully do what I need.

Still ... as I am using FMPA 12 and none of my images are references to folders because as an old FMP user as I once lost the referenced folder and had a lot of probmles since.

Now what happens with FMPA is as follows the images "randomly" vanish from the db. However I did a

IfEmpty(Pics) loop and apparently the images are there but FMPA only shows the rotating spiral arrow and no picture.

I assume the images are somehow embedded inside the file is there a way to get them back? Recovering doesn't do anything.

The value for $filePath should be Get(DesktopPath) & MyPics::Description & ".jpg" . Is what you wrote above a transcription error?

Since you have FMPA, use the Data Viewer to verify that $filePath resolves to a valid path.

You haven't specified a folder. The $filePath you (almost) specified would put the file directly on the desktop (Unless MyPics::Description contains a folder reference).

If you wanted it in a folder, your script should read something like

Set Variable [$folder; Value: "MyFolder/"]

Set Variable [$filePath; Value: Get(DesktopPath) & $folder & MyPics::Description & ".jpg"]

FileMaker can't create folders; you would have to use a plugin or Applescript to create one earlier in the script.

The mistake comes from this page actually in FMP help

[help.filemaker.com/app/answers/detail/a_id/5822/~/exporting-the-field-contents-of-a-container-field]

I simply tried and tried to use it.

Is this a working applescript for this task?

set specificFolder to (choose folder)

tell application "FileMaker Pro Advanced"

tell database "ThisHomework"

tell table 1

set thisID to field "STUDENTID"

set thisFile1 to field "PIC1"

set thisFile2 to field "PIC2"

set thisFile3 to field "PIC3"

set thisFile4 to field "PIC4"

set thisFile5 to field "PIC5"

end tell

end tell

end tell

set tc to (count thisID)

tell application "FileMaker Pro Advanced"

repeat with i from 1 to tc

set archiveName to item i of thisID & " " & item i of thisFile1

do script "Export PIC1"

delay 5

do script "Export PIC2"

delay 5

do script "Export PIC3"

delay 5

do script "Export PIC4"

delay 5

do script "Export PIC5"

delay 5

end repeat

end tell

Thanks A lot

dan

Link to comment
Share on other sites

Put this calculation in the data viewer, and see what it gives you for an image that works, and for an image that doesn't:


Length( STUDENTS::PIC1 )

This will return the size in bytes of the file if it is stored in the container field or the length of the text reference to the file if it was stored as a reference. In other words, if it returns a small (3 digit) number then the file isn't stored in the database.

Sorry, I can't help with applescript.

Link to comment
Share on other sites

This topic is 4288 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
×
×
  • Create New...

Important Information

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