Support Article

Remove file from service export directory



How can we remove a jar file from a directory automatically after the product import is complete.



While there is no out of the box activity that deletes a particular file. This is possible via a custom activity.  The following is an example of code for deleting only the service export directory where the jar files or temporary attachments reside before they are imported into the database. If you want to delete any particular file from this service directory, you will have to make sure to get the file handle for that specific file using the absolute filepath or the PRFile API.


String tempPath = tools.getProperty("pxProcess.pxServiceExportPath").getStringValue();

PRFile afile = new PRFile(tempPath);

String list[] = afile.list();

for (int i = 0; i < list.length; i++) {


  afile = new PRFile(tempPath+list[i]);

  oLog.infoForced("delete Status"+afile.delete());



There is also an option from the SMA to delete the entire static content cache.

Suggest Edit

Published January 31, 2016 - Updated October 8, 2020

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.