How to get parent directories from pentaho variable

80 Views Asked by At

In Pentaho the directory where the current job is stored in the variable:

${Internal.Job.Filename.Directory}

But how can I move backward to get the parent directories ? I want to use it to set a variable value.

Any help please !!!

1

There are 1 best solutions below

2
Bert-Jan Stroop On

${Internal.Job.Filename.Directory}/..

from there you can just continue in the path. So if you need to go up one folder and then in a folder parallel to your files directory named folderA, just use:

${Internal.Job.Filename.Directory}/../folderA

going up multiple folders is also possible:

${Internal.Job.Filename.Directory}/../../../folderA

Followup question: How to set this as a variable?

To set this as a variable, just at the beginning of the job make a transformation step, calling a new transformation.

enter image description here

and then in the transformation:

enter image description here

Then you can use the new relative path (in this case 4 levels up and then into the temp folder, leading to "c:/temp") anywhere within followup transformations by calling ${filepath}