Hi! I’m trying to export a few images from a filemaker database. What would be the best way to do this? And could the exported image file names be grabbed from another field in the same record? I’m using filemaker 10. The database has 320 records.
There are 2 different ways to Insert a picture in FileMaker. It is controlled by a checkbox in the Insert dialog, on the lower left:
[ ] Store only a reference to the file
If it is not checked, then you will “embed” the picture into FileMaker, the whole thing. If you check it you will embed only a reference to the picture file’s location on the drive. The picture will look the same in either case. Embedded pictures will render a little faster.
If you used AppleScript to put the image into FileMaker, you’ll have a referenced picture.
You can tell which you have by creating a calculation, result Text. Let’s say your container field is named: Image
GetAsText (Image)
This will return only 1 line if the file is embedded, the name of the file. It will return 3 lines if the [x] Store only a reference is checked. Example:
size:640,480
image:…/ContainerPictures/Brooklin.jpg
imagemac:/Macintosh HD/Users/fej/Documents/FileMaker/My_FM/CONTAINER/ContainerPictures/Brooklin.jpg
The last line is the absolute path to the file, in FileMaker syntax. So, my method of getting just the name is to take the last line, and the text after the last “/”. This works for either embedded or referenced; though if you have only embedded, you only need GetAsText (Image).
Let ( [
txt = GetAsText ( Contain );
path = GetValue ( txt; ValueCount (txt));
pat = PatternCount ( path; “/”);
pos = Position ( path ; “/” ; 1 ; pat )
];
Right ( path; Length (path) - pos)
)
So, that’s the name. Or, if you already have a name in another FileMaker field, just use that.
Now how to Export. You can control Exports (and anything else with a similar dialog, such as Import), by setting a Script Variable to the path (in FileMaker syntax). This is a script step. Then you use that variable as the path in the Export dialog. Look at the 3rd line above to see what the FileMaker syntax path looks like. Once you’ve set Script Variable to the full path, you just put that variable in the Export dialog. No quotes, just (whatever your variable name is; I’m just using $path):
$path
There are other functions for getting special paths, like the Desktop:
Get (DesktopPath)
returns (for me):
/Macintosh HD/Users/fej/Desktop/
notice the beginning and ending slashes.
Always review your paths. Most errors are caused by a slight mistake in the path (missing FileMaker prefix, too many slashes at the beginning, etc.). Create a calculation so you can see it, or use the Data Viewer.
You can also ask questions at: http://www.fmforums.com
We can upload example files there.