Save the output file in the same folder as the input file

Hi,
I want to save automatically my output file in the same folder as the input file.
The output file name is controlled by a variable => done.

I had an idea: get the input path and concatenate it with the output filename. but I can’t put the input path in a variable !

have any ideas please?

Hi @mosmel

I’ve prepared short workflow that creates variable from the input filename, and then grabs the path to folder. Is this something you are looking for?

Happy KNIMEing,
Kaz
Folder_path.knwf (14.3 KB)

2 Likes

Hi @mosmel and welcome to the Knime Community

That’s one way to do it, and that’s what @Kazimierz has demonstrated.

Another way would be to define the path before even reading the file. I mean when you are reading your input file, you need to go somewhere. Then why not define this as a variable before hand and re-use this variable for output path after? :slight_smile:

In fact, this can easily be achieved using the Create File/Folder Variables node:

It’s literally made for purpose of creating variables to hold folder and file names/path. It will generate variables of type path for you

2 Likes

Thank you for your answer,
I thought about this but I can’t link node “Path to String (variable)” to node “Excel Reader” !

thank you for your answer, i will check this track and get back to you :slight_smile:

It’s OK, problem solved. thank you :slight_smile:

@mosmel After adding some nodes to workflow, variable ports are hidden by default. To unhide variable ports one needs to right-click appropriate node and select Show Flow Variable Ports option.

Please remember to mark the solution that match your expectations by clicking ‘Solution’ button.

Have fun with your workflow,
Kaz

3 Likes

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