Skip to main content

TrFile_MoveFolder (function reference)

By January 1, 2021March 30th, 2022Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_MoveFolder
Troi File Plug-in for FileMaker Pro


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

SyntaxFunction badge

TrFile_MoveFolder ( switches ; sourceFolderPath ; destinationFolderPath )


switches reserved for future use, leave empty or set to "-Unused"
sourceFolderPath the path to the source folder to move
destinationFolderPath the path where the folder must be moved to

Returned Result

Data type returned

Error code


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 4.0


FileMaker Pro 16 to 19


You can use the function TrFile_DeleteFolder 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 TrFile_CopyFolder function and (optionally) use the TrFile-DeleteFolder 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:

Set Field [ gErrorCode ; TrFile_MoveFolder ( "-Unused" ; "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 Mac OS 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:

Set Field [ gErrorCode ; TrFile_MoveFolder ( "-Unused" ; gSourceFolderPath ;  gDestFolderPath ) ]

This will move the source folder to the path indicated in the gDestFolderPath.

Used in example files


Related functionsFunction badge


Related script stepScript step badge

Move Folder

Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 16 to 19 –> TrFile_MoveFolder (filep4297) 2022-0330 17:36:19