filter text by date in path

hello everybody

I have a variable that has today’s date, and I have an input file with some files, I would like only the folder whose name is the same as my variable to go forward

my variable

My file

Hi @gabrielfs2

I’d use indeed the String Manipulation node to create a column that you than can use in a “Row filter” or “Row splitter”

you can then use the RegexReplace on that variable you have, but you would need to get a bit familiar with the syntax.

something like “(.*)([0-9]{4}-[0-9]{2}-[0-9]{2})(.*)” and capture that part via the “$2” replaceStr parameter of the function.

regexReplace( $my_path$, “(.*)([0-9]{4}-[0-9]{2}-[0-9]{2})(.*)” , “$2” )

you could feed that value “2023-04-03” into a ‘string to date&time’ node and do calculations on it to get the ‘current date’ or ‘most recent date’

hope that gives you a bit of a start ?


Just be careful, the Regex I mentioned is far from robust!

You’d want to craft it a bit so that it matches on a specific part of the path and does not match on the file names etc etc… to make it more robust



Hi @gabrielfs2

An alternative approach is to evaluate the path of the parent of the files. It requires fewer nodes:


You can do this via a combination of the contains(), getParent() and today() functions in a Column Expression node:


It’s pretty straightforward as it checks if the folder path where the file is located in contains the date of today. It will return a true/false which you can subsequently filter on.

Note that this setup depends on that the date format used in the folder name is the same as a KNIME LocalDate which the today() function uses.

Hope this helps!


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.