Appearance
FileCon.MoveFile
Declaration
function MoveFile (const aDestPath, aDestName: string): boolean;
Example
pascal
procedure OnStartMapEvent;
var
vFilePath, vFileName, vFileExt, vTimestamp: string;
vMovedOK: boolean;
begin
// split full file name into path, name, and extension portions ...
vFilePath := ExtractFilePath(Source.FileCon.CurrentFileName);
vFileName := ExtractFileName(Source.FileCon.CurrentFileName);
vFileExt := ExtractFileExt(Source.FileCon.CurrentFileName);
vFileName := ChangeFileExt(vFileName, ''); // remove file extension
// build a timestamp, to add to the file name ...
vTimestamp := FormatDateTime('yyyymmddhhnnss', Now);
vFileName := vFileName + '_' + vTimestamp + vFileExt;
vMovedOK := Source.FileCon.MoveFile(vFilePath, vFileName);
if vMovedOK then
LogInfo('Timestamp appended to file name')
else
LogError('Error appending timestamp to file name');
end;Description
When a File Definition is used with an Action, the MoveFile function can be called to move a file to a new location and/or to give a file a new name. If aDestPath is the same as the file's current path, then MoveFile renames the file within that directory path.
MoveFile returns True if the move or rename is successful; MoveFile returns False if the move or rename fails. MoveFile will fail if the specified values are not allowed as a file path or file name .
The MoveFile function realigns the File Con with this new file location and/or name. Any further functionality like Transports will use the new moved file. For example, when the File Con audit functionality occurs it will take the file from the moved name/location and move it to the corresponding audit folder on completion of the Action.
If the target directory path does not exist, Flow will attempt to create it automatically.
File utility functions such as ExtractFileName are described under Scripting Reference, Functions, File.
Also, for file activity not involving Flow Source or Destination files, see Windows File Functions.