Set Default Folder [ Result ; Where ]
Set Default Folder sets the default folder for all MediaManager functions that depend upon a file path.
Parameter | Description |
---|---|
Result | An optional target field to receive any error. Will be left empty when there is no error. |
Where | Any absolute path or path relative to the current default folder. See also special values below. |
An item cannot be renamed to the same name as an existing item in the same folder.
Special values for path
Value | Meaning |
---|---|
.A | Applications (Mac) or Program Files (Windows) folder |
.D | Desktop |
.F | The folder containing the currently active FileMaker Pro application |
.O | Documents folder |
.P | Preferences folder |
.R | The root folder of the boot disk |
.S | System folder |
.T | Temporary folder |
.U:prompt | user selects a folder from the folder dialog |
.V:prompt | user selects a file from the file dialog. Returns filename, sets default folder to the file’s enclosing folder. |
.W | Windows folder (Windows only) |
.X | Trash folder |
.@ | Downloads folder |
.d | Documents folder |
.m | Music folder |
.p | Pictures folder |
.v | Movies folder (Mac), Videos folder (Windows) |
The above codes can be used anywhere a file path is expected. Special values can be combined with relative paths. For example, “.D/foobar/image.jpg” refers to the file image.jpg inside the images folder on the desktop.
At startup, the default folder is set to the root disk.
Path Syntax
All paths to files and folders used by MediaManager follow the conventions of FileMaker Pro. An absolute path starts with slash; relative paths do not. A path to a folder ends in slash; a path to a file ends with the file name. Here are some examples:
An absolute path to a user directory named “Frank” on the Mac:
/Macintosh HD/Users/Frank/
An absolute path to a user directory named “Frank” on Windows Vista and newer:
/c:/Users/Frank/
A relative path to a file named “MyFile.txt” located on the desktop:
.D/MyFile.txt
The Default Folder
MediaManager uses the convention of the “default folder”. This path is set either by using the Media_SetDefaultFolder function or by Set Default Folder script step and is automatically prepended to every file or folder path specified in MediaManager functions. In other words, you can set the default path to any folder, and then simply set all paths to be relative to that default location.
For example, suppose the default path is set to the Desktop folder, with either one of the following:
Set Default Folder [ Where: “/Macintosh HD/Users/Frank/Desktop/” ]
Set Default Folder [ Where: “.D” ]
If you then use a MediaManager function like Media_ExportField or Export Field script step, you can simply list the file name in the path parameter, and the file will be exported to the desktop (the default folder):
Set Field [ MyTable::Response ; Media_ExportField ( MyTable::Picture 1 ; “image.jpg” ; False ) ]
Export Field [ Result: MyTable::Response ; Field: MyTable::Picture 1 ; Destination: “image.jpg” ; Replace: No ]
Similarly, if you want to specify a folder within the default folder, you only need to list the folder and file name, and MediaManager understands that you are specifying a location relative to the default folder (again, the desktop):
Export Field [ Result: MyTable::Response ; Field: MyTable::Picture 1 ; Destination: “MyPictures/image.jpg” ; Replace: No ]
Of course, you can specify a full path at any time and the default path is ignored.
Other Special Notations
../
refers to the enclosing or “parent” folder. It is the equivalent of going “up one level” in the current default path.
For example, if you set the default path is set to a user directory like this–
Set Default Folder [ Where: “/c:/Documents and Settings/Frank/” ]
–you can then specify the Users directory with “../”, such as in a Export Field script step like:
Export Field [ Select; Result: MyTable::Response ; Field: MyTable::Picture 1 ; Destination: “../image.jpg” ; Replace: No ]
Returns
An empty string if successful. Otherwise, returns an error message.
With either of the user prompt options (.U and .V), if a user clicks on the Cancel button, MediaManager returns “$0:Cancel”.
Examples
To set the default folder to the desktop:
Set Default Folder [ Select; Result: MyTable:Response ; Where: “.D” ]
To set the default folder to the boot disk:
Set Default Folder [ Select; Result: MyTable:Response ; Where: “.R” ]
To allow the user to select the default folder with the message “Select a default folder”:
Set Default Folder [ Select; Result: MyTable:Response ; Where: “.U:Select a default folder” ]