How to get the current working directory

I’m having trouble finding the exact answer I’m looking for.

When I distribute the Knime workflow files to users. I export to .knwf files. The problem is that my desktop’s input and output directories differ from the user’s desktop’s. Thus, for every Knime workflow, the input and output paths must be modified. In Knime process, I would like to set up a dynamic input and output path. Here’s my solution.


Hi @ktthana ,

Welcome to the KNIME community

Firstly you shouldn’t need to replace / with \ in your paths

Although \ is naive to Windows, paths containing “/” should work fine on all systems ( including Windows).

It isn’t clear though what your actual problem is. Are you saying your solution doesn’t work or that it does work but you are wondering if there is an alternative?

If you are looking for an alternative perhaps you can give more information about what type of folder structure differences are that you are trying to handle?

Is your folder location relative to your workflow?

btw I have edited the title of your post from “directly” to “directory”. Hope that is correct.


Hi @ktthana
As @takbb implied you can read and write your data relative to the stored KNME workflow. See reader and writer nodes

1 Like

Thank you @takbb , @Daniel_Weikert.

Sorry for my miscommunication. actually I intent to share a solution. i have been trying to search from Google but there is no what I need. The current path actually it is easy to get from “Extract Context Properties” if you are working under Knime local workspace. But if you export it to Knime workflow file (knwf) then the current path will include temp path. I share my logic how to handle it. So with this wherever location you can get the right current path.
Maybe you may have better solution would be helpful to learn.

Here’s the context property in case of running through Knime work file on local drive.

Here’s running through workflow under local workspace.

@ktthana I have a component that would determine the data directory and also derive the actual path separator:

@mlauber71 Thank you for your suggestion. I’m not able to get the component due to company policy. Do you have a way to get it rather than drag and drop?


@ktthana you can download the component itself as a .knar file and import it into KNIME. Also each workflow that uses the component will also have a copy.

Collect Local Metadata.knar (19.9 KB)

Thanks @mlauber71. I can download it and it works if I import it to my local workspace. But when I export the workflow to knwf file and paced the knwf file to C:\data path. It comes with temp path as below.

This can be solved by using this expression.

It now return the right path.

1 Like