Skip to main content

Exchange Files (script step reference)

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

Exchange Files

Exchanges two files on disk

SyntaxScript step badge

Exchange Files [ Select ; Result (error) ; FilePath 1 ; FilePath 2 ;
                 Allow different Volumes ]


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
FlePath 1 the path to the first file
FilePath 2 the path to the second file
Allow different volumes allows the exchanging of files between different volumes (disks)

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 files were exchanged
$$-43 fnfErr one (or two) of the files not found
$$-1303 diffVolErr the 2 files are on different volumes

Other errors may be returned.

Originated in

Troi File Plug-in 10.0


FileMaker Pro 17 to FileMaker Pro 21 (2024)


You can use the Exchange Files step to quickly replace a file with an updated file.
When the step returns the error code $$-1303, you can use the checkbox Allow Different Volumes.


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

  gErrorCode		Global, number
  gFilePath1		Global, text
  gFilePath2		Global, text

gFilePath1 and gFilePath2 should contain the path to existing files, for example “D:\Logs\Current.TXT” and
“D:\Work\Updated.TXT”. In a script add the following script steps:

Exchange Files [ $ErrorCode ;  gFilePath1 ; gFilePath2 ]
Set Field [ gErrorCode ; $ErrorCode // save the error code too ]

This will (quickly) exchange the two files. After this step the file “D:\Logs\Current.TXT” will have the contents of “D:\Work\Updated.TXT” and vice versa.

Example 2

In a script add the following script stept:

Exchange Files [ $ErrorCode ; "Update Disk:NewData.fmp12" ; 
				"Work Disk:DataDB.fmp12" ; Allow different volumes" ]

This will exchange the two files, even if the files are on two different volumes (disks).

Used in example file


Related script stepsScript step badge

Copy File
Delete file
Move File

Related functionFunction badge


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 16 to 2024 –> Exchange Files (filep7317) 2024-0604 18:58:29