Moves a folder to the specified folder path. Can also be used to rename the folder.
Move Folder [ Select ; Result (error) ; Source folderPath ; Destination folderPath ]
|Select entire contents||replaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field|
|Result (error)||an error code|
|Source folderPath||the path to the source folder to move|
|Destination folderPath||the path where the folder must be moved to|
Data type returned
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
|0||no error||the folder was moved to the new place|
|$$-43||fnfErr||source folder not found, or destination folder does not exist|
|$$-48||dupFNErr||destination folder already exists|
|$$-122||badMovErr||the destination folder is inside the source folder|
|$$-1407||errFSNotAFolder||the source is not a folder|
Other errors may be returned.
Troi File Plug-in 9.0
FileMaker Pro 16 to 19
You can use the Delete Folder script step to delete a folder first if it exists at the destination.
On Mac this function only works when the source and destination folder are on the same disk. If this is not the case, use the Copy Folder script step and (optionally) use the Delete Folder script step function to delete the source folder.
Assume your C disk already contains a folder “TestFolder” and a folder “MyFiles”. We assume that a global number field gErrorCode is defined. Create the following script:
Move Folder [ Select ; $ErrorCode ; "C:\TestFolder" ; "C:\MyFiles\MovedFolder" ) ]
This script will move the folder “TestFolder” and its contents to the “MovedFolder” folder inside the folder “MyFiles” on the C: disk. On macOS the paths will be of the form “Mac HD:MyFiles:MovedFolder”.
Notice that the destination folder has been renamed.
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number gSourceFolderPath Global, text gDestFolderPath Global, text
gSourceFolderPath should contain the path to an existing folder, for example “D:\Logs\” (Windows) or “Mac HD:Logs:” (Mac). gDestFolderPath should contain the path to the destination and should not exist, for example “D:\Logs\L2007_12” (Windows) or “Mac HD:Logs:Log 2007_12” (Mac). In a script add the following script step:
Move Folder [ Select ; gErrorCode ; gSourceFolderPath ; gDestFolderPath ) ]
This will move the source folder to the path indicated in the gDestFolderPath.
Related script steps
Troi File Plug-in online help (overview)