Home > OS >  Get Filename with current date using regex
Get Filename with current date using regex

Time:02-24

I have a situation where I have to get a new file every day at a specific time which is saved automatically on a specific folder on a remote server using GETSFTP Processor.

for example today there will be a file created on a remote server named 20220223.csv (23rd of Feb current date). P.s I want to get only one file of the current date and I don't want to update my filename in the GETSFTP processor dynamically every day.

this is my try but it gets all the files available.

NOTE: Expression Language is not supported.

NOTE: Expression Language is not supported.

CodePudding user response:

As you know the file name is `yyyyMMdd.csv' you don't need to use a file filter regex.

Instead, use an UpdateAttribute to set a filename attribute with ${now():toDate():format('yyyyMMdd')}.csv.

In GetSFTP, set theRemote Path property to /home/data/user/${filename}.

Note: You could also combine that into just the GetSFTP with Remote Path set to /home/data/user/${now():toDate():format('yyyyMMdd')}.csv, I just like the readability of UpdateAttribute

  • Related