Dynamic file name path, change according to user

Hi Knime Community,

I am trying to change a part of the path when reading/writing files in my workflow, so that my colleague does not have to change at every reader/writer node. For now my files read/written using the following structure “C:\Users\MyUsername.LastName\Desktop\MyFile.csv” where the username is my name since I created the workflow. This means that every reader/writer node, my colleagues needs to manually change the username name in the path to put his own, and this takes time and leads to errors.

Basically I need the “name.lastname” part of the location to change when a different person opens and runs the workflow without having to manually change in every single reader/writer node.

I have gone through many threads but can’t seem to find a answer that allows me to fix this. One easy option would be to save files and folders one level above our usernames in the directory, but this is not optimal.

Is there a way the path can be changed depending on “who” is running the workflow? And if yes, which changes do I need to make in the original workflow to get this “flexibility”? What I need is that for every reader/writer node throughout the workflow, the username part of the file location changes to the current user.

I’ve tried flow variables but I’m unable to set a flow variable for only a “chunk” of the path (i.e. the part containing username). In another thread I came across the Extract Context Properties node, which creates variables for things such as username, but I am not able to use later to create a variable when reading the files.

Thanks for your help, much appreciated!! :relaxed:

Hi @PLS_KN and welcome to the Knime Community.

There are 2 parts to discuss here:

  1. How to change the location in “every single reader/writer node”
  2. How to determine who is the current user

For #1:
You can do this by “centralizing” the location into a variable, and then use that variable in “every single reader/writer node” that uses that location. That way, even if #2 cannot be achieved, your colleague would have only one place to change this value.

For #2:
Knime cannot know what’s your first name or last name, since you don’t really fill up a profile. It can know what’s your username. Now, your username could be in the format of firstname.lastname, but this whole combination would be your username. This would seem to be your case.
You can use the Extract System Properties to get the username of the current user (check RowID user.name)

Here’s a little workflow that I put together that can help you extract the user name as variable:
Get username as variable.knwf (7.9 KB)

Combining both #1 and #2 should do what you want to do.


The best way to do that is to use a Local File Browser Configuration – KNIME Hub node wrapped inside a component. This way all your coworkers need to do is to configure that node.


1 Like

Hi Bruno,

thanks for having a look at my issue.
For #1 What do you mean by “centralising” the location into a variable and how is this done? The thing is, the workflow uses many locations, i.e. one location per file/folder that we read and other locations also to write processed files. Would centralising work in that case?

For #2 indeed I can get the user name using the Extract System Properties node. But from there how can I use this as a flow variable for “part” of the location? It won’t let me… and the other option would be to create a table with and appending the beginning of the link + the user name + the location of file. Not sure how efficient that would be though.


Hi Gabriel,
If I use this node in a component, does the whole Workflow need to be in the component too? And if I use this, how do I initially set up the reader nodes configuration? I have about 10 reader nodes, so the location needs to change in all of them depending on the user.


No, you just need to wrap that node itself, so that the configure dialog can be used.

Take a look at this example workflow I build, that demonstrates how to create paths dynamically based on a users home directory: Path manipulation examples – KNIME Hub

1 Like

Hi @gab1one and @bruno29a

Thanks for your tips, I think I found a way using a mix of these things. It seems to work now, I will need to ask my colleague to confirm.

It looks like this (I modified the file names here since I cannot share the data)
Path_Manipulation_Username.knwf (30.3 KB)

Thanks a lot!

Hi @PLS_KN , there are many ways to do #1 and #2, and even the combination of both can be done in different ways.

Looking at your workflow, you kind of centralised the location via a table, and then did some processing and converted to variable:

So you understood it, although you can do this directly as variables, using Variable Expression.

You can replace all of the above by 2 Variable Expressions like this:

These 2 highlighted parts will give you the same variables and values. Details as follows:
In the first Variable Expressions, I define a base path like this:

This will create a variable called “basePath” with value “C:\Users\<dynamic_user_name>\Documents” for example “C:\Users\bruno\Documents” or in your case “C:\Users\patricia.llull\Documents

It’s too bad we can’t use the variables defined in the same Variable Expressions, and because of that, I have to use another Variable Expressions to be able to use the basePath variable. So my 2nd Variable Expressions looks like this:

I just join the basePath variable with each of the values you want.

FYI: I ended up not using your table, as I’m not sure what’s the purpose of the File_or_Folder column - I mean I can guess what the purpose can be, but I don’t see it being used in your workflow. The rest of the columns of your table is taken care of in my Variable Expressions.

Here’s the workflow containing these 2 Variable Expressions that you can use to replace the manipulations you are doing:
Path_Manipulation_Username - Bruno.knwf (33.8 KB)


Amazing thanks!! This works and it’s more convenient than what I did initially :slight_smile:

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