Solved

Text File Writer: adding a datetime as suffix to an output file

  • 29 November 2023
  • 2 replies
  • 56 views

Userlevel 4
Badge +4

Hey all,

I was wondering if you ever came accross the following requirement and has some tips maybe to implement it.

The Text File Writer step can be used to create for instance log files. For tracking or governance reasons it may be necessary to keep all log files. But because the output file name is fixed, each time the file will be overwritten whenever a new one is created. Of course it is possible to manually add a datetimestamp to the file name after its creation, but that is a rather cumbersome approach. So I would like to be able to add a datetimestamp to the file name automatically. 

Does anyone have a suggestion?

Kind regards,

Albert

icon

Best answer by SamWrigley 30 November 2023, 00:37

View original

2 replies

Badge

Hi Albert, 

My approach to this is by adding the Alter Format step before the Text File Writer step.
For my purpose I use date and timeNow with the following expressions, if you want a datetime stamp you can just add the time format to the date expression.


In the Text File Writer step you can then set the filename using this syntax,

{date}/logfile_{timeNow}.txt

In this example it creates a new folder with todays date and adds the time to the logfile. ​​​

Userlevel 4
Badge +4

Hi Sam,

That is a really nice solution, thanks a lot 😀!

Regards,

Albert

Reply