You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by mtigua <mt...@gmail.com> on 2019/03/21 19:27:49 UTC

Get files using ListFile but filtering by its name that has a date inside it

Hello everyone, please help!

I have files whose name is formed by a date in the format "yymmdd", for
example:

TRB_ASE_D190125.txt

TRB_TIT_D190125.txt

I need to get only the files whose names match the current date. For
example, if the date was "190125", the 2 subsequent files would match that
criterion.

I am using the ListFile processor to get the files and put this regular
expression using the "now" function in the File Filter, but it does not
work:

^TRB_[A-Z]+_D${now():format('yymmdd')}.TXT



Thanks in advance!



--
Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/

Re: Get files using ListFile but filtering by its name that has a date inside it

Posted by Peter Turcsanyi <tu...@cloudera.com.INVALID>.
Hi,

File Filter property of ListFile does not support expression language so I
am afraid you will not be able to use the now() function there.

As an alternative solution, you can use ListFile without filtering and add
RouteOnAttribute after ListFile with the following match condition against
the filename:
${filename:matches(${now():format("'TRB_[A-Z]{3}_D'yyMMdd'\.TXT'")})}

There might exist a more elegant solution though...

Best,
Peter

On Thu, Mar 21, 2019 at 8:28 PM mtigua <mt...@gmail.com> wrote:

> Hello everyone, please help!
>
> I have files whose name is formed by a date in the format "yymmdd", for
> example:
>
> TRB_ASE_D190125.txt
>
> TRB_TIT_D190125.txt
>
> I need to get only the files whose names match the current date. For
> example, if the date was "190125", the 2 subsequent files would match that
> criterion.
>
> I am using the ListFile processor to get the files and put this regular
> expression using the "now" function in the File Filter, but it does not
> work:
>
> ^TRB_[A-Z]+_D${now():format('yymmdd')}.TXT
>
>
>
> Thanks in advance!
>
>
>
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
>