TrFile_MoveFile (function reference)

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

TrFile_MoveFile

Moves (or renames) a file from one location to another.

SyntaxFunction badge

TrFile_MoveFile ( switches ; sourceFilePath ; destinationFilePath )

Parameters

switchesmodifies the behavior of the function
sourceFilePaththe path to the file to move
destinationFilePaththe path where the file must be moved to

Switches

Switches can be empty or this:

-AllowDifferentVolumesallow the move between different volumes (disks). Moving a big file across disks may take more time.

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 moved
$$-43fnfErrSource file not found, or destination directory does not exist
$$-48dupFNErrDestination file already exists
$$-1303diffVolErrThe 2 files are on different volumes
$$-4254returnInPathErrThe path contains an illegal return character
$$-1genericErrThe file could not be moved

Other errors may be returned.

Originated in

Troi File Plug-in 1.1

Compatibility

FileMaker Pro 13 to 17

Considerations

TIP: You can also use this function to rename a file
See also the functions TrFile_SelectFileDialog and TrFile_SaveFileDialog to get a filePath for a file.

When the function returns the error code $$-1303, you can use the switch -AllowDifferentVolumes.

Example

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:\New\L2000_01.TXT” (Windows) or “Mac HD:New:Log 2000_01” (Mac). In a script add the following scriptstep:

Set Field [ gErrorCode ; TrFile_MoveFile ( "-Unused" ; gSourceFilePath ; gDestFilePath ) ]

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

Example 2

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

Set Field [ gErrorCode ; TrFile_MoveFile ( "-Unused" ; "C:\Testtext.txt" ; "C:\NewName.txt" ) ]

This script will move (rename) the file “Testtext.txt” to the “NewName.txt” file in the same directory. Note that on Mac OS the paths will be like: “Work Disk:NewName.txt”.

Related functionsFunction badge

TrFile_CopyFile
TrFile_CreateFile
TrFile_SaveFileDialog
TrFile_SelectFileDialog

Related script stepScript step badge

Move File

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 13 to 17 –> TrFile_MoveFile (filep4262) 2018-0515 15:49:53