Give KNIME workflow a name with a date and time stamp

Hello all,

I am trying to figure out a way to dynamically name workflows in KNIME so that they automatically include a date and time stamp. I’m hoping to come across something similar to the Java Snippet that many use to name files when using the ‘Writer’ nodes (example here). In the example, the .csv file that is exported has the date and time as a suffix in file name.

Is this possible: (e.g., exampleFlow.knwf -> exampleFlow_07-May-2020.knwf). Manually naming the files and including the date is unfortunately not an option.

Any instruction and/or direction would be greatly appreciated!


Hi there @dg-clarkston,

if I may ask why do you need date and timestamp in workflow name? And also what date and timestamp should it have? When workflow started/finished?

Anyways should be possible with creating workflow including Copy/Move Files node with appropriate logic.


Hello @ipazin,

I’ve been instructed by those above me that the workflow name and date needs to be included in order to help them locate and note when specific models were created. There are probably much better monikers BUT I’m focused on sticking with my instructions. The date and time should include the date (YYYY-MM_DD) and time (HH:MM). The files are on the KNIME server but I figured it out using the Java Snippet.


Glad to hear you figured it out.

1 Like

CORRIGENDUM: It turns out that the individuals wanted the workflow name itself to be included as a prefix in saved files and a date & time stamp as a suffix.

I was able to accomplish this using the Extract Context Properties and Java Edit Variable nodes. The former allows for specific information to be extracted from the environment and used as a flow variable – so I specified This was then used as a flow variable in the latter node. A quick example of my use is as follows:

I wanted to export a model that was run in my workflow as a PMML file. My java code included:

// expression start
    public void snippet() throws TypeException, ColumnException, Abort {

// Enter your code here:

//Replace this with whatever - possibly an incoming flow variable
//windows OS path location
StringBuilder fname=new StringBuilder("C:\\file-path-location\\");

//name of model to be saved
StringBuilder modName=new StringBuilder("gbt_115");

// See for format codes
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy_HH-mm");

out_timestamp = sdf.format(new Date());
//v_contextworkflowname is the flow variable!
out_filename = fname+v_contextworkflowname+"_"+modName+"_"+out_timestamp+".pmml";



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.