Export Field [ Result ; Field ; Destination ; Replace ]
Export Field exports field contents as an external file.
Parameter | Description |
---|---|
Result | Optional. A target field to receive any error. Will be left empty when there is no error. |
Field | The field containing the image, sound, file, text, or reference to export. |
Destination | A full file path, or partial file path that picks up with the default path. If the source is a reference, then the destination can be a path to a folder; otherwise, it must be a path to a file. |
Replace | Set to “Yes” if you want to replace an existing file with the same name. If “No” (default), an error will be returned if the target file already exists. |
Export Field is a universal script step for exporting any type of container or text field to a file.
File Name Extension
In most cases you do not need to know or specify the file extension in advance.
If the destination extension is not specified in the filename portion of filepath parameter, MediaManager will use the following logic:
- If the contents of a text field are being exported, a text file (.txt) will be created.
- If the source is a reference within a container, the extension of source file is used.
- If the source is stored directly in a container field and is a recognized data type, the appropriate extension is used.
- If the source is not a recognized type, no extension is placed on the destination file name.
If the destination extension is specified, it is used.
If the source is a container reference to another file, you can specify a folder destination without a file name. In that case the referenced file is copied to the destination folder using its original name.
Exported Image Format
When exporting images that have been manipulated by other functions resulting in MMIM format (see the Displayed Image Formats section), convert the image to a standard image type before exporting. MediaManager will give an error if you attempt to export from a container field that holds only an MMIM image.
Container Field Text Note
After using the “Insert Picture” command by reference, the container field is temporarily of type text immediately afterwards. Export Field will export the text (a file path) rather than the referenced file itself. If you manually click out of the container filed or use the Commit Record script step, the container field contents are then converted to the correct type.
Returns
Empty string when no error is detected; otherwise error text is returned to the response field.
Examples
To export a JPEG image from a container field named “Picture 1” to the desktop with a file name of “exported image.jpg”:
Field: MyTable::Picture 1 ;
Destination: ".D/exported image.jpg" ;
Replace: No ]
To export the image from a container field named “Picture 1” to a folder named “images” located in the current default folder:
Field: MyTable::Picture 1 ;
Destination: “images/exported image.jpg” ;
Replace: No ]
To export an image from a container field named “Image” to the current default folder and using the contents of a field named “Image Title” as the file name:
Field: MyTable::Image ;
Destination: MyTable::Image Title ;
Replace: No ]
To allow the user to select a destination, and then export an image using the contents of a field named “Image Title” as the file name storing any potential error into MyTable::Error:
Where: ".U:Where to export the image to?" ]
Select; Result: MyTable::Error ;
Field: MyTable::Image ;
Destination: Image Title ;
Replace: No ]
To export an image, setting the replace parameter so the exported file will replace any file with the same name in the destination location:
Field: MyTable::Image ;
MyTable::Image Title ;
Replace: Yes ]
To export a sound from a container field named “Sound Clip” to the current default folder and using the contents of a field named “Sound Name” as the file name:
Select; Result: MyTable::Response ;
Field: MyTable::Sound Clip ;
Destination: MyTable::Sound Name ;
Replace: No ]
To export text from a text field named “Notes” to the current default folder and using the contents of a field named “Description” as the file name:
Select; Result: MyTable::Response ;
Field: MyTable::Notes ;
Destination: MyTable::Description ;
Replace: No ]
To copy an image from a Web site directly to disk, without using a container field:
$URL; "https://cdn.pixabay.com/photo/2014/11/30/14/11/kitty-551554_640.jpg” ]
Select;
Result: MyTable::Response ;
Field: Media_InsertImage ( $URL ; False ) ;
Destination: ".D/kitty.jpg" ;
Replace: No ]