Search code examples
muledataweavemule4anypoint-studiomule-connector

How to move a file in a folder with timestamp in mule 4


I have a file which is flatfile I want to move to a specific folder. Please help me in achieving this. I tried the below expression targetPath="#['C:\workspace\file\src\main\resources\move' ++ (as DateTime as String {format: 'yyyyMMddHHmmss'})]"


Solution

  • If you are using the SFTP connector Move operation:

    <sftp:move config-ref="file" sourcePath="#[vars.source]" targetPath="C:\workspace\file\src\main\resources\move" createParentDirectories="true" renameTo="#['myfile ' ++ (now() as String {format: 'yyyy-MM-dd\'T\'HH:mm:ssX' }++ ".dat")]"/>
    

    The <file:move> operation uses the same attributes. Warning: using colons (:) in file names is not valid in Windows filesystems.