If you ever wanted to automatically remove older files than (n) days in multiple directories you probably struggle with batch and PowerShell scripts or even with manual deletion using explorer.
We have the ftp server with users’ directories and one public directory so everyone could write to it. Users’ files should remain 30 days and files from public directory only for 7 days.
Empty directories should be purged.
Download MSH Delete Files Older Than, unzip compressed file, run the EXE application. No installation is needed.
Click Add button to open Rule wizard. First we need to specify which folders should be cleaned, start with public folder. Click Add button then Browse and choose public directory. Select Include sub folders and Delete empty folders option.
Switch to Time page. Leave modification time option in Match files by criteria. Our directory should be cleared from files older than 7 days. Select Match files which are OLDER than 7 DAYS.
Switch to Files page. We want to remove all types of files, but if there will be requirement to remove only specified files, we could define which file names should be deleted.
Switch to Action page. Now we need to define what to do with old files. By default files are deleted permanently. We could also move them to recycle bin, move or copy to other directory and even compress while copying. Leave Delete files permanently option.
Switch to Name page. Change the rule name to something meaningful, like Remove files from public directory. Click OK button.
Now it’s time for users’ directories. Once again click Add button to edit new rule. Go through each page like when we were defining rule for the public directory. Just change 7 to 30 days on Time page.
In this post I tried to describe how rules could be created to delete files in different directories and with different time frame.
Defined rules can be now start manually by clicking Run button or scheduled to run automatically on defined time.
To learn more visit MSH Delete Files Older Than website.