Requirement: we have two different folders eg: input and output Input folder contains different files, here we need to write the files to the output folder with the same file names based on the time stamp that is created.

Note: File should be write based on the time that is created eg: First in First Out.

1

There are 1 answers

0
aled On

You can use the List operation of the File connector. It returns an array for each matching file in a directory. Each entry contains in the payload the contents of the file but also attributes like creationTime.

You can sort the list using this criteria with a DataWeave expression. For example payloadd orderBy ($.attributes.creationDate).

Then iterate over each with a foreach to write each entry as a separate file using the Write operation.

Example:

<file:list doc:name="List" directoryPath="someDirectory"/>
<ee:transform doc:name="Transform Message">
    <ee:message>
        <ee:set-payload ><![CDATA[
            %dw 2.0
            output application/java
            ---
            (payload orderBy $.attributes.creationTime) ]]>
        </ee:set-payload>
    </ee:message>
</ee:transform>
<foreach doc:name="For Each">
    <file:write ... >
</foreach>