Use of Relative Path - What am I doing wrong?

I have a file that I wish to copy and later read.
It appears to be a good idea to use relative path names.
So I have created a mySQL query which returns my file name with the path attached to it.

knime://knime.workflow/JOBOURKE_11006_25.xml

I have a step further on which converts this value into a variable.

When I execute the workflow, I get an error. The console window I believe shows the exact issue.
It says as follows

Exceute failed: knime:\knime.workflow\PHOLLIER_11076_18.xml (The filename, directory name or volume label syntax is incorrect)

It appears that the workflow is not interpreting my path correctly. Or is it?
What am I doing wrong here?

Hi @Shai
your string should contain backslash “\” instead of “/” and should look like “C:\[Folder]\[File]” for local located Files or “\\[Server]\[Folder]\[File]” for server located files.

BR
Hermann

1 Like

I think you have to show us the node where you use this path. With the KNIME protocol you will have to use “custom path” not relative path.

https://www.knime.com/knime-introductory-course/chapter2/section1/absolute-and-relative-paths-knime-protocol

As a heavy user of KNIME protocol I am not 100% happy with this shift.

2 Likes

The mistake was this: I was hardcoding the ‘knime.workspace’ bit.
knime.workspace is more of a variable and not a literal.
It translates to the literal value at the time of execution.
The variable was sitting right in front of me everytime I was setting up my string manipulation node.
Nevertheless, this is what seems to be the behavior…

Incorrect use: “knime://knime.workflow/Myfoldernames/Myfilename”
Correct use: join($${Sknime.workspace}$$,"\\Myfoldernames\\Myfilename")

Yes @morpheus , I took the blue pill.
I discovered the left slash was the right pill.

So that was all good until…
There is another hurdle that I ended up in this process. I’m not happy with my solution to it.

My workflow copies certain files in certain specific folders within the workspace.
e.g \Myfoldernames\Myfilename

But the workflow expects “\Myfoldernames” to be already available.
If its not already setup, the workflow gives an error.
So I had to create another workflow to ensure that all sub folders are available prior to running my workflow. I’m not happy with having to create a separate workflow.

Is there a file creation, copy, or move node that will automatically create the folder if it is not available?

This was annoying but not a show stopper so I shall come back to this and fix it.
If you know a better solution, it will help.

1 Like

Makes sense.
In my situation, I need also to ensure that the path is available via a variable.
So had to use a string manipulation node > join function

I wonder if you agree with my second post on this thread where I claim that I found the solution.
Is there a better way?

I think I am going to try and use variables for the user name and password!
That was my D-Oh! My Homer moment.

There are also the credentials nodes to save you managing variables :slight_smile:

image

1 Like