How to rename a source file with the current datetime

Illustrated below is an example of a flow where the Relay Based Filesystem source step is used, a Calculator step is added to rename the new file, a Combine step and CSV Writer step will create the new file with the new name and the file will be sent back to the local system using the Relay Based Filesystem destination step.

The below image is the Relay Based Filesystem source step where the relay is selected and a path is inputted. No other configuration has been changed.


The image below is the file that is located in the Path field in the Relay Based Filesystem source step.

Illustrated below is the Calculator step where a parameter is created for the file name and a created path is inputted where the new file name will contain the extracted datetime (from the fields in the Detailed view) and the file type.

NB: The datetime will be in a UTC timezone.

The below code is used in the above Calculator step:

let inputRecord=input.record;
input.parameters.fileName = 'C:\\TestPath\\FileMoved_' + input.runInfo.year + '_' + input.runInfo.month + ':' + + '_' + input.runInfo.hour + '_' + input.runInfo.minute + '_' + input.runInfo.second + '.csv';
return inputRecord;

The below image is the Relay Based Filesystem destination step where the same relay as the source is selected and the parameter name (highlighted in the Calculator step) is referenced in the Path field by clicking on the highlighted link icon. The Create Path check box will be ticked if it the path in the Calculator step is a created path and not an existing path.


The below page is the new renamed file in the given path.