Copy File (script step reference)

By May 1, 2017May 20th, 2020Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

Copy File

Copies a file to the specified path.

SyntaxScript step badge

Copy File [ Select ; Result (error) ; Source filePath ;
            Destination filePath ]

Options

Select entire contentsreplaces 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 filePaththe path to the file to copy
Destination filePaththe path where the file 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:

0no errorThe file was copied
$$-43fnfErrSource file not found, or destination directory does not exist
$$-48dupFNErrDestination file already exists
$$-4254returnInPathErrThe path contains an illegal return character
$$-1genericErrThe file could not be copied

Other errors may be returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 16 to 19

Considerations

You can use FileMaker styled paths, like “filemac:/MacHD/folderA/test.txt”.
Use the Delete File script step to delete a file first if it exists. See also the script step Show Save File Dialog to get a Filepath for a file.

Example

Assume your C disk already contains a file “Testtext.txt”. We assume that a global field gErrorCode is defined. Create the following script:

Copy File [ Select ; gErrorCode ; "C:\Testtext.txt" ; "D:\MyFiles\TestDupl.txt" ) ]

This script will copy the file “Testtext.txt” to the “TestDupl.txt” file in directory “MyFiles” on the D: disk. On Mac OS the paths will be of the form “Mac HD:MyFiles:TestDupl.txt”.

Example 2

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

  gErrorCode		Global, number
  gSourceFilePath	Global, text
  gDestFilePath		Global, text

gSourceFilePath should contain the path to an existing file, for example “D:\Logs\Log01.TXT” (Windows) or “Mac HD:Logs:Log 1” (Mac). gDestFilePath should contain the path to the destination and should not exist, for example “D:\Logs\L2000_01.TXT” (Windows) or “Mac HD:Logs:Log 2000_01” (Mac). In a script add the following script step:

Copy File [ Select ; gErrorCode ; gSourceFilePath ;  gDestFilePath  ]

This will copy the source file to the path indicated in the gDestFilePath.

Related script stepsScript step badge

Copy Folder
Create File
Delete File
Show Save File Dialog
Show Select File Dialog

Related functionFunction badge

TrFile_CopyFile

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 15 to 19 –> Copy File (filep7210) 2020-0520 15:35:09