How to do loop in pentaho for getting file names?

Cynosure picture Cynosure · Dec 7, 2012 · Viewed 15.3k times · Source

I have 100 000 files. I want to get the name of those file names and have to put in database, I have to do like this

  1. get 10 files name's;
  2. update/insert names into database; and
  3. move those 10 files to another directory; and loop these three steps till no files are found.

Is this possible?

Answer

Milos picture Milos · Dec 10, 2012

I'm attaching a working example (I tested it with ~400 text files on kettle 4.3.).

transformation.ktr job.kjb

Both transformation and job contain detailed notes on what to set and where.

  • Transformation.ktr It reads first 10 filenames from given source folder, creates destination filepath for file moving. It outputs filenames to insert/update (I used dummy step as a placeholder) and uses "Copy rows to resultset" to output needed source and destination paths for file moving.
  • job.kjb All the looping is done in this job. It executes "transformation.ktr" (which does insert/update for 10 files), and then moves those 10 files to destination folder. After that, it checks whether there's any more files in source folder. If there is, process is repeated, if not, it declares success.