0

As the title says, I'd like to know how to create a folder with current date(dd/mm/yyyy) (on Job). I've seen two answers but they seemed quite long, for example this one: pentaho create archive folder with MM-YYYY

Anyone has an idea? Thanks :)

1 Answers1

2

That answer is also from 2014, better and newer versions of PDI are out, and this answer is overcomplicating the task.

Though you do need to create the folder name in a KTR, you can just use the 'Create folder' Job step. I'm pretty sure you cannot set AND use a variable in the same JOB/KTR that you have set it to begin with. So you need a KTR that generates a Date and sends it as string to a JOB.

Your KTR should like this, to create a String date with the format YYYY-MM-DD

enter image description here

And your Job like this

enter image description here

Also remenber, you can't create folders with '/', so you have to use another pattern.

This is a very simplistic approach, there are other ways to automate folder creation through use of variables.

EDIT: Corrected the JOB image, the first KTR needs to actually run for the variable to be set, sorry for the confusion.

Cristian Curti
  • 1,004
  • 1
  • 7
  • 13
  • 1
    Thanks a lot for the reply! I did exactly the same thing as you, however, think it doesn't consider the variable "today" because in error message, it says "Folder [D:\pentaho\data\archive\] exists, failing. ". I set the job parameter as you showed, on Create a folder step, I put "D:\pentaho\data\archive\${today}" as folder name and did the same thing on KTR as well. On Generate rows step, I didn't put anything on fields, am I right? –  Jun 03 '19 at 14:20
  • Ah, sorry ... i did the job wrong ... The KTR needs to actually run for the variable to be set.. silly me. I'll correct the answer. – Cristian Curti Jun 03 '19 at 14:25
  • And yes, you don't need to set anthing on Generate rows, just change it to Generate 1 row instead of 10, or else the Set Variables step will fail. – Cristian Curti Jun 03 '19 at 14:30
  • It works perfectly !!!! Thank you so much, have been searching for the solution for hours! Thanks a lot a lot :))))) –  Jun 03 '19 at 14:34