Skip to main content

Move Folder (script step reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

Move Folder

Moves a folder to the specified folder path. Can also be used to rename the folder.

SyntaxScript step badge

Move Folder [ Select ; Result (error) ; Source folderPath ;
              Destination folderPath ]

Options

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

Returned Result

Data type returned

Error code

Result

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.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

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.

Example

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.

Example 2

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 stepsScript step badge

Copy Folder
Delete Folder
Move File
Reveal Folder

Related functionFunction badge

TrFile_MoveFolder

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> Move Folder (filep7297) 2024-0604 19:10:05