Generate a Dynamic Filename Based On Date / Timestamp in Talend

If you’re working with Talend Open Studio and would like to dynamically specify the name of a file you’re attempting to consume or output, refer to the following.

  1. Create a new tSetGlobalVar object
  2. Double-click the tSetGlobalVar object to open the Component tab.
  3. Within the Component tab, create a new key with the value “timestamp” and set the value to: TalendDate.getDate(“yyyy-MM-dd KK.mm.ss a”) // This will create a string with a value similar to “2012-01-04 04;06;54 PM”
  4. Double-click the file you wish to input/output.
  5. Under “File Name”, enter somwething similar to “C:/Talend/Projects/MYProject/My File ” +  ((String)globalMap.get(“timestamp”)) + “.txt” // Obviously, replace the path, filename and file extension with whatever you’re working with. If requested, I will post some screen shots.
  6. That’s it!

Leave a Reply