How to remove filename from Path?

Hello. Is there a way to remove the excel file name from Path?
Example… if I have an excel file with multiple row referencing different Paths
(ie. C:\doc1\doc2\file1.xlsx), how do extract the folder/directory portion only (C:\doc1\doc2)?

I’ve try searching and trying for the past 2 hours… no luck :frowning:

Thanks in advance.

Hello @amateur ,

if your path is in path format (not in string!) you can use a column expression node and a getParent() formula.
Have a look at this part of the column expressions node (functions under “Path” section) and at the workflow below.

Have a nice day,


Hello @amateur
Besides @lelloba solution based in Column Expression node; you can achieve the disclosing of the Path with KNIME base nodes by concatenating ‘Path to String’ and ‘URL to File Path’ nodes.



P.S. Just for the records; this option can be valid as well:


Hi @amateur , if it is sobering you need to do often, I have a component which iirc encapsulates the functionality described by @gonhaddock.

It was something I found myself occasionally needing to do and could never remember how to do it :wink:


I just remembered that I redid this component and created two new components, with very odd sounding names but they perform the same job:

One to handle a String column

One to handle a Path column.

1 Like

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