title: Comparing filenames in PDI
body: <p>I am trying to import a certain .CSV file into my database using PDI (Kettle).</p>
  
  <p>Normally this would be rather easy, as you could just link up a <code>CSV file input</code> step with a <code>Table output</code> step and be good to go. However, the problem is that I don't know which file I want to import in advance, as in before executing the job/transformation in PDI.</p>
  
  <p>That is because I have many files in my import folder, which all have the same format regarding their filename: <code>KeyDate_Filename_YYYYMMDD.CSV</code></p>
  
  <p>The idea is to have file with the newest YYYYMMDD imported for a given key date.</p>
  
  <p>My theoretical approach to implement this would be:</p>
  
  <ul>
  <li>Make the given key date available in PDI as a parameter (already done)</li>
  <li><strong>Read in the names of all files stored in the import folder</strong></li>
  <li><strong>Filter said filenames for the given key date</strong></li>
  <li><strong>Compare the YYYYMMDD of the remaining files and select the newest</strong></li>
  <li>Use selected filename as parameter in a <code>CSV file input</code> step (already done)</li>
  <li>Import data via <code>Table output</code> step (already done)</li>
  </ul>
  
  <p>Unfortunately I am fairly new to PDI and don't really have a compelling idea on how to implement the bold parts or if that approach as a whole is even viable.</p>
  
  <p>Can anybody think of a way to get this done? Appreciate any feedback</p>
  
  <hr>
  
  <p>Edit: Forgot to mention that I am using PDI 3.2.6. </p>
  
  <p>In 4.x.x I could simple use a User Defined Java Class to get this done :/</p>