Skip to main content

Copy Folder (script step reference)

Troi File Plug-in for FileMaker Pro

Copy Folder

Copies a folder to the specified folder path.

SyntaxScript step badge

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


Select entire contents replaces the 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 folder to copy
Destination folderPath the path where the folder must be copied 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 copied
$$-43 fnfErr Source folder not found, or parent folder of destination folder does not exist
$$-48 dupFNErr Destination folder already exists
$$-1234 The destination is inside the source
$$-1407 The source is not a folder

Other errors may be returned.

Originated in

Troi File Plug-in 9.0


FileMaker Pro 16 to FileMaker Pro 2023


You can use FileMaker styled paths, like “filewin:/C:/dir/subdir”.
Use the Delete Folder script step to delete the destination folder first if it exists.


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:

Copy Folder [ Select ; gErrorCode ; "C:\TestFolder" ; "C:\MyFiles\CopiedFolder" ]

This script will copy the folder “TestFolder” and its contents to the “CopiedFolder” folder inside the folder “MyFiles” on the C: disk. On macOS the paths will be of the form “Mac HD:MyFiles:CopiedFolder”.
Notice that the destination folder has been renamed too.

Example 2

We assume that in your FileMaker file the following fields are defined:

  gSourceFolderPath	Global, text
  gDestFolderPath	Global, text
  gErrorCode		Global, number

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:

Copy Folder [ Select ; gErrorCode ; gSourceFolderPath ; gDestFolderPath ]

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

Related script stepsScript step badge

Copy File
Delete Folder
Move Folder

Related functionFunction badge


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 16 to 2023 –> Copy Folder (filep7296) 2023-0601 16:18:24