Hello Sourabh,
You can delete files from a directory in the app server using JS functions.
You need to make use of the file.remove() function if the Jsapi.chm documentation.
Please follow the steps mentioned below:
Create a new workflow and name it as per convention.
Drag and drop the 3 workflow activities(start , JS and End) on to the canvas and then connect them.
Double click on JavaScript code activity and rename it to your liking.
Insert the following code inside JavaScript activity to fetch our goal.
// Define server folder path where to search for
var strFolderPath = "/usr/local/neolane/nl6/var/Client/workflow/"
// In the above path "client" is your instance name
// Define file match pattern
var strPattern = "*.txt"
// We are looking for all files that have an extension as csv
// Open a directory object to fetch its data
var objDirectory = new File(strFolderPath)
// Get access to all files inside the directory that match the search pattern
var objFiles = objDirectory.list(strPattern)
// Log the count of files
logInfo("No. of files that match search criteria are : " + objFiles.length) -- This step is optional and needed just if you need to verify the number of files
// remove all the files in the directory /usr/local/neolane/nl6/var/Client/workflow/
for each(var objFile in objFiles)
{
objFile.remove();
}
**************************************************************************************************************
Please take a look all other patterns that can help you search.
"*.*" : all files.
"*.txt" : all text files.
"A*.*" : all files whose name start with A
"A*z.*" : all files whose name start with A and ends with Z.
Regards,
Adhiyan