TrFile_CopyFolder |
Copies a folder to the specified folder path.
Syntax
TrFile_CopyFolder ( switches ; sourceFolderPath ; destinationFolderPath )
Parameters
switches | reserved for future use, leave empty or set to "-Unused" |
sourceFolderPath | the path to the folder to copy |
destinationFolderPath | the path where the folder must be copied 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 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 4.0
Compatibility
FileMaker Pro 17 to FileMaker Pro 21 (2024)
Considerations
You can use FileMaker styled paths, like “filewin:/C:/dir/subdir”.
Use TrFile_DeleteFolder to delete the destination folder first if it exists.
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:
Set Field [ gErrorCode ; TrFile_CopyFolder ( "-Unused" ; "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:
Set Field [ gErrorCode ; TrFile_CopyFolder ( "-Unused" ; gSourceFolderPath ; gDestFolderPath ) ]
This will copy the source folder to the path indicated in the gDestFolderPath.
Used in example file
FolderManipulation.fmp12
Related functions
TrFile_CopyFile |
TrFile_DeleteFolder |
TrFile_MoveFolder |
Related script step
Copy Folder |
Related topics
Troi File Plug-in online help (overview)