Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
in CompleteFTP by (47.9k points)

A user asked us:

How do I have CompleteFTP delete files that are older than 14 days?

1 Answer

0 votes
by (47.9k points)
edited by
Best answer

You could use a scheduled process trigger to periodically call a JSS script that iterates through a folder-tree deleting any files that are older than 14 days.

Something like the following should do the trick:

Inline images 1

Here's the script so that you can copy-and paste:


var maxAgeInDays = 14;
var baseFolder = "/Home";

// Deletes all files in the given folder (and all its sub-folders)
// that are older than maxAgeDays
function deleteOldFiles(folder) {
    folder.getFiles().forEach(function(f) {
        if (f.isFolder())
        else {
            var now = new Date();
            var msPerDay = 1000*60*60*24;
            var ageInDays = (now.getTime() - f.modifiedTime.getTime()) / msPerDay;
            if (ageInDays > maxAgeInDays)

// Call removeOldFiles on the base folder