'Mule 4 adding a timestamp to a filepath location and name

Path folder/finename

Path folder/finename

So the folder name that I want to save the file in is "output" and "ScheduleTest.csv" this is the filename I like to call it, but I want to add a timestamp to it. This is on a File Write module. Does anyone know how to do that in expression mode?

<file:write doc:name="Write" doc:id="bba24eb0-8f63-4b6c-9c40-b5529325b4ea" config-ref="File_Config" path="output/ScheduleTest.csv" mode="APPEND">
        <file:content><![CDATA[#[output application/csv header=false --- payload]]]></file:content>
    </file:write>


Solution 1:[1]

In an expression you can use DataWeave expressions to create the timestamp as needed:

path="#['output/ScheduleTest.csv' ++ now() as DateTime as String {format: 'yyyyMMddHHmmss'} ]"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1