I don't have an immediate answer. What version of FM are you using? And can you find the images manually, but need a way to do it programmatically?
I am using FM Pro 14, and I can insert each image back manually but due to time restriction, I would like to do it programmatically. Hope I'm answering your questions.
If you can determine the name of the file and a location for it, then a script can insert the file for you.
I suspect that you can access the file name from the container field even though it fails to "connect" to the file. If you did not use the "secure" option for your container than you might very well be able to set up a script that loops through your records and re-inserts them from that folder or from a duplicate of that folder.
yes, you did - but I should have also asked if you are on Windows or Mac.
Hopefully, you can import these file paths and recreate the references you need.
That's good news! Do you happen to have a sample script or some sort that can navigate me to bring back the lost images? Honestly, I never wrote a script before and got no idea of how to do it.
I am using Windows, and thank you for your references. I will do some homework and hopefully find a solution to this issue.
Am I correct about the following?
You have records where no file/image shows in the container field and see something like "file missing".
You specified external storage but did not specify "secure"
You can find the "missing" files in the folder set up to store your externally stored images.
I'll have to test this to be absolutely sure, but I believe that even with the file "missing", we can extract the file name from the container field. If we can't, then my idea here won't work.
You are absolutely correct on all three.
Just for curiosity, how does specifying "secure" deffer from "open storage"?
It's my understanding that the files are then encrypted, which would keep us from inserting files from that folder.
But I've just run a test. I can definitely get the filename and file path even after I move the file out of the remote storage folder by treating the container field as a text field and using GetValue ( containerfield ; 2 ) to get both the name and original location of the file.
I also found that if I moved the file back into the folder, it no longer shows up as "missing".
So before I spend more time playing with this...
Are you absolutely sure that the file is in that remote folder?
Or do you have this file in a different folder and it just needs to be put back into that folder?
Yes, I am sure all the files are in the remote folder and I am only using one PC, if that info helps you.
I am using FM Pro 14, and I can insert each image back manually...
Please describe the manual process for us. Thanks.
I just right click in the container field and "insert picture" from the original folder where I saved all images (this is different from the external storage folder). I have done a few hundreds of that in the past month, and those files are also saved in the external storage folder as soon as I insert them, and some of them are duplicated because all images were saved in the folder once before.
thank you - my Eastern Daylight Time brain can't get to it now. I think somebody else will help before I can.
Ok, that explains the observed difference in my test--that moving the file back into the "remote" folder restored the connection automatically.
Since the path to your folder is known, you can extract the file path from the container field and combine that with the known filePath to automatically re-insert any images "not found" in your container fields that are also present in this other folder.
I'd do something similar to this:
a) Establish the actual path to your folder of images from which you need to do the inserts. One way to do this is to Insert any file from that folder into a container field with the "by reference" option specfiied. Then this expression will return the file path and file name: GetValue ( ContainerField ; ValueCount ( ContainerField ) ). You can pull that up in a calculation field that returns text or, if using FileMaker advanced, a Watch expression in the data viewer. You can then copy all but the file name from that text to the clip board to paste into your script to use when computing the file path to use to insert a missing image file.
b) add a calculation field that returns text something like this:
GetContainerAttribute ( YourContainerField ; "FileName" )
Then perform a find for all records where this field is empty (use a lone = operator in that field). This function returns no value when the file shows as "missing".
c) then run this script on the found set thus produced:
Go To record/request/page [first]
Set Variable [$FileName ; value: //put following calc here ]
Let ( [ Text = GetValue ( YourTable::YourContainerField ; 1 ) ;
Len = Length ( Text )
Right ( Text ; Len - 7 )
Set Variable [$Path ; PasteYourFilePathHere & $FileName ]
Insert File [YourTable::YourcontainerField ; No Dialog ; $Path ]
Go to Record/request/page [next ; exit after last]
Note: You will get error messages interrupting this script if there is no such file in your folder.