Adobe Campaign provides very limited ways to handle the folder structure on the servers or more precisely directory cleanup. This is indeed understandable from security point of view. But at the same time, we have some use cases where we may need to do periodic cleanup in order to keep it optimal particularly Export or Upload folders.
Some possible scenarios are:
- All export files need to temporarily stored on AC filesystem before sending to SFTP or as an attachment. This is required so we can refer than with concrete path while sending.
- As part of development/testing, we may end up unnecessarily adding multiple versions of files to the export or upload folders. This will surely eatup the allocated server space on longer run.
- Extra care of handling these orphan files may be required in case the files contain PI information.
- Remove dependency on Adobe Support/Tech Ops to address these issues and be owner of the task yourself. Since you are the one who know the files exactly and their naming pattern, thus can easily search and delete these files.
//Update FOLDER_PATH per your client's AC box
var FOLDER_PATH = "/usr/local/neolane/nl6/var/<CLIENT_NAME>/export/"
//Update FILE_NAME_PATTERN with wild card
"*.*" : all files
"*.txt" : all text files
*.csv" : all csv files
"A*.*" : all files whose name starts with 'A'
"A*Z.csv" : all csv files whose name starts with 'A' and ends with 'Z'
var FILE_NAME_PATTERN = "*.csv"
var objDirectory = new File(FOLDER_PATH)
var objFiles = objDirectory.list(FILE_NAME_PATTERN)
logInfo("Count of files that match search criteria are : " + objFiles.length)
for each(var objFile in objFiles)
//For other properties of objFile (the File object), refer AC's jsapi.chm documentation
logInfo("Deleting file: " + objFile.name + " - last modified at " + objFile.lastModified);