pentaho create archive folder with MM-YYYY

2019-08-10 12:25发布

I would like to archive every file in a folder by putting it in another archive folder with a name like this: "Archive/myfolder-06-2014"

My problem is how to retrieve the current month and year and then how to create a folder (if it does not already exist) with these data.

1条回答
Ridiculous、
2楼-- · 2019-08-10 12:47

This solution may be a little awkward (due to the required fuss) but it seems to work. The idea is to precompute the target filename in a seperate transformation and store it as a system variable (TARGET_ZIP_FILENAME):

Transformation for retrievign the target zip filename

The following diagrams show the settings of selected components.

  • Get the current time...

Get current time

  • Provide the pattern of the target filename as a string constant...

Provide target filename pattern

  • Extract the month and year as formatted integers...

Extract month and year from current time

  • Replace the month in the pattern (the year will work equivalently)

Replace month in pattern

  • Set the resulting filename as a system variable

Set variable containing target filename

The main job will call the transformation and use the system variable as the zip target filename.

Main job

Also you have to make sure that the setting Create Parent folder is active: Settings of the 'zip file' component

查看更多
登录 后发表回答