Support Questions

Find answers, ask questions, and share your expertise

Who agreed with this solution

avatar
Expert Contributor

Without knowing how the FTP directory is populated, you might have an issue with the ListFTP state and might consider changing its its Listing Strategy,

However assuming that is no issue and you want to only perform an action based on any file with a naming structure like this: xxxx-xxxx-xxxx-xxxx-20220121110000-xxxx-xxxx.csv and only if it is older than two hours from "now"

I would run the output of your ListFTP to an UpdateAttribute and add these 2 properties:

 

property name       

fileTime         

value

${filename:getDelimitedField(5,'-'):trim():toDate('yyyyMMddHHmmss'):toNumber()}

property name

timeNow                     

value

${now():toNumber():minus(7200000)}

 

Then route that to a RouteOnAttribute and add a new property:

 

property name              value

2 hours old                ${fileTime:le(${timeNow})}

 

Then you can drag that connection to follow on processing and the unmatched connection to other processing or terminate it.

 

Explanation:

filelName

${filename:getDelimitedField(5,'-'):trim():toDate('yyyyMMddHHmmss'):toNumber()}

This grabs the time out of your filename and converts it to a Date object so it can be converted to its epoch representation

 

timeNow

${now():toNumber():minus(7200000)}

Sets a value 2 hours ago from current time

 

 

${fileTime:le(${timeNow})}

If attribute fileName is less than or equal to timeNow it means that it is 2 hours old.

 

 

 

View solution in original post

Who agreed with this solution