This article explains how to create a process, which will delete unnecessary files, so as not to overload the folders.

This example shows how to delete xml files, which are automatically generated by the runtime, when invoking a webservice. 


It can be easily adapted to delete other files from another folder.

In this article, you will find the following steps :

  • First step : detect if files are present in the folder
  • Second step : check the last modification date of the file
  • Third step : delete selected files
  • Last step : execute the process


First step : detect if files are present in the folder


After creating a process, we will use the FileWait action, which is dedicated to wait and detect a file or a set of files in a given folder.


In this example, we choose to delete xml files from the runtime temporary folder.

A session parameter can be retrieved with this expression : 

${/CORE_JAVA_TEMPORARY_FOLDER}$

'Wait File Nb Files' is set to '-1', to indicate we don't know how many files are expected.


Second step :  check the last modification date of the file


If the file is older than seven days, we want to remove it. This check will be done in a script; if the file needs to be removed, its name will be added into a list of files, and the list will be stored in a process parameter.

We need to create a parameter to store the files list to be deleted.



Name it, for example, 'listOfFiles'.


Then, we will control the date with a scripting action. 

Make a Bind link between the File Wait action and the scripting one.

As the link is a bind one, we can retrieve properties of the detected files. Their values are bound and can be retrieved with this syntax :{column}: .


The script code can be the following one, in rhino :

var date = new java.util.Date();
var currentTime = date.getTime();
var listOfFiles = __ctx__.getVariableValue("../listOfFiles");

if (currentTime - :{FILE_LAST_MODIFIED}: > 604800000)
{listOfFiles = listOfFiles + ':{FILE_NAME}:' + ';'}

__ctx__.publishVariable("../listOfFiles",listOfFiles);


Third step : Delete selected files


Now, we have a list of files, whose names are separated by a semicolon. We can add a Delete File action to remove those files from the folder.

The parameter 'Del Includes' will be set with the list of files generated in the script and the 'Del  Dir' will be set with the runtime temporary folder.

A process parameter can be retrieved with this expression :

${../listOfFiles}$

'../' means that the parameter is held by the parent process of the current action.


Last step : execute the process

This process can be scheduled to be executed every day or week, depending on the number of daily API calls.