You can use Export Field Contents to export the file to a location you specify (put file name and file path in a variable).
Then Use insert file to re-insert the file from the new location and you will have moved your file. (Use the same variable as it has the filepath and file name you need.)
You can even use export field contents with a path to the original file, but with no field specified to delete the original, but that is an option to use with care so that a mistake does not delete the wrong file.
Thank you, works perfect !
The script works perfect on Mac, but now that I transferred the FMP file on Windows I'm not able to open the re-imported file saved as a reference by double clicking on the container field. Somehow it seems that the Mac recognizes the file type and opens it correctly and not Windows.
Here is my script:
Set Error Capture [On]
Insert File [HistoricNotes::Attachments]
Set Variable [$FileName; Value:Historic::HistoricID]
Export Field Contents [HistoricNotes::Attachments, "$FileName"]
Insert File [Reference; HistoricNotes::Attachments; "$FileName]
Is there a way to get the file extension of the original file, set it in a variable and add it to the exported FileName?
It's not the script, but rather that the filepath to the file is different on your two platforms.
The image must be stored in a shared directory directly accessible from both machines, but the two systems format the same file path differently.
Try this out to see what I mean.
Define a calculatton field and set it to return text.
Enter the name of your container field as the sole item in its calculation.
Put this field next to your container field on your layout and size it to be 4-5 lines to text tall. You may need to click into it or give it a scroll bar to seen the entire text.
Now insert a file by reference into the container field and note what text is stored. Do this on both machines.
In order for both to see the image, you need either an indentical path to the image file or a calculation field that identifies the operating system of the current user and returns the correct file path for that platform. Either that or you use a web viewer to display the image file with a URL calculation that uses the same methods to produce the appropriate file path.