Jump to content

Container field - migrate jpgs from embedded to external folder


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

Recommended Posts

Hello

I have read the thread below about a script that will export container images to an external folder

I have 11000 jpgs embedded in an FM file and I wish to migrate these files from an embedded state to an external folder.

Go to Layout [ MyPics ]
Show All Records
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

Firstly, I am unsure if the above script rewrites the container path to the new folder or just exports the data but leaves the container intact.

Any thoughts would be most helpful.

Thank you

Link to comment
Share on other sites

32 minutes ago, chlowden said:

I am unsure if the above script rewrites the container path to the new folder or just exports the data but leaves the container intact.

It only exports the images to the user's desktop (there is no "new folder" in the script you show). No change takes place in the exporting file. To have the container field point to the exported file, you must reinsert it as reference only. Or change the field to a calculation field, calculating the path from the Description field.

P.S. Make sure you have a backup before you try any of this.

 

Edited by comment
Link to comment
Share on other sites

Thank you for clarifying this.

To be honest, I'm no script writing, and I have searched

"container calculate path" on the site but nothing very pertinent comes up.

Could you advise me where I might find an example script?

Also, I would seem logical that the path change be part of the migrate script .. Or that not such a good idea?

Many thanks

Link to comment
Share on other sites

Your script could look something like:

Go to Layout [ MyPics ]
Show All Records
Go to Record/Request/Page [First]
Loop
  Set Variable [$filePath ; Value: Get ( DocumentsPath ) & "ExportedImages/" & MyPics::Description & ".jpg"]
  Export Field Contents [MyPics::Picture ; “$filePath”]  
  Insert File [ Reference ; Target: MyPics::Picture ; “$filePath” ]
  Go to Record/Request/Page [Next ; Exit after last]
End Loop

This will export the images to a folder named "ExportedImages" located in the user's Documents folder, and reinsert them as reference only into the original container field.

Learn more about setting up the insert file step:
https://help.claris.com/en/pro-help/content/insert-file-options.html

 

Link to comment
Share on other sites

Thank you so much for sharing the above.

Maybe you can where I am stumbling as I get generic error on the script below

Go to Layout ["Images" (Image); Animation:None]
Show All Records
Go to Record/Request/Page [First]
Loop
  Set Variable [$$filePath ; Value: " Set Variable [$$filePath ; Value: Get( C:/Users/christ/Desktop/FM_EXPORT/HTML_files/images/ ) & Images::ContainerFieldName & \".jpg\"]"
  Export Field Contents [Images::Image ; “$$filePath”]  
  Insert File [ Reference ; Target: MyPics::Picture ; “$filePath”; Create directory:On ]
  Go to Record/Request/Page [Next; Exit after last: Off]
End Loop

Layout name : Images

Container field name : Image

Original file name : ContainerFieldName

 

Below is my attempt to migrate the jpgs to the folder

C:/Users/christ/Desktop/FM_EXPORT/HTML_files/images/

My first question is that the script uses / like on mac when PC usually uses \ (which is what I am using.) But when I use \ in the script I get errors.

image.thumb.png.c7ae918203a23f798b2853f1093544ac.png

 

I took example for the Insert File element  from the link below as I did not understand why I need the Option box.

https://help.claris.com/en/pro-help/content/insert-file.html?Highlight=insert file

Below is the error. The user account admin and there is plenty of space on the hard drive.

image.thumb.png.5193c98e0928c2ac4038600d061f9d3a.png

Any thoughts are most welcome.
Thank you

Edited by chlowden
Link to comment
Share on other sites

I see several errors:

First, you're not setting the variable correctly. You should name the variable $filePath (not $$filePath ), then click the Specify… button for the Value and enter the following formula exactly as it appears here:

Get ( DesktopPath ) & "FM_EXPORT/HTML_files/images/" & Images::ContainerFieldName & ".jpg"

Next, use the variable $filePath when exporting the image - again, not $$filePath .

Finally, this part makes no sense to me:

2 hours ago, chlowden said:
Insert File [ Reference ; Target: MyPics::Picture ; “$filePath”; Create directory:On ]

Your table is named Images and your container field is named Image - so how can you possibly use MyPics::Picture? Do you even have such table/field? Also, Create directory:On is not an option for the Insert File script step. 

 

Note: Filemaker uses its own paths, not your OS paths. See:  
https://help.claris.com/en/pro-help/content/creating-file-paths.html

Link to comment
Share on other sites

Whilst trying the troubleshoot the file name issue, I stumbled on the Container Storage option below.

image.thumb.png.35ef7eca3184fba6ad44cfa636275181.png

By clicking on the Store container data externally check box, it extracted virtually all the pictures to a folder and updated the ContainerFieldName field.

image.thumb.png.ca1a3290ef6bb35bc9a32621aeb4e4c3.png

A csv export shows that the database looking to an external source.

Link to comment
Share on other sites

1 hour ago, chlowden said:

symbols that Windows does not like

I am afraid I have no clue what that means.

 

36 minutes ago, chlowden said:

Store container data externally

You never told us what is the purpose of this migration. I don't have time to go into details, but you should be aware that external storage is very different from having files inserted as reference only.

 

Link to comment
Share on other sites

The conflict with Mac & PC special characters in file names e.g. *µç¤ etc

I have now read that external referenced files was deprecated sometime ago and external storage is now the revised method. I must confess that I have not used FM for nearly 10 years and I struggled with it in version 7 to 12. I used FM as a web server and at the time, the images in  containers had to be internal.

My goal is to extract the files and have the database intact. Once that done, either continue with FM or migrate to a php solution.

Many thanks for all your help

Edited by chlowden
Link to comment
Share on other sites

This topic is 1002 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.