FTP search of older files and delete them






1.50/5 (5 votes)
May 25, 2004
1 min read

44682

698
Mark all the files on an FTP site that are older than a specified time and delete if required.
Introduction
This utility allows one to mark all the files on an FTP site that are older than a specified time. The user may then choose to delete those files/dirs.
Code references
I have used:
- The FTP library provided by http://www.enterprisedt.com/.
- Code to parse the file info returned by the FTP site. (I tried to find out where I got that code from and found the same code at different places. So I will just put this note here that the
ParseDosDirLine
andParseUnixDirLine
is not my code.)
Usage
- To preconfigure your servers, add the server/user/password in the options.xml file.
- Start the program.
- Set the 'Time before now' value as required.
- Choose to "Check directories" if you want the date of the directories also to be checked.
- Enter any comma separated strings in "Ignore Dirs with substring" if you do not want to scan directories that contain the specified substring.
- Click Scan.
Known issues:
- The program runs in a single thread and it might seem dead while the FTP site is being scanned.
- If there is an FTP error, the scan has to be restarted. Not much error checking and recovery is being done.
This is a quickly put together piece of code that could have a whole lot of functionality added. Feel free to make changes and post the code.
Suggested improvements
- Make the program multithreaded, and responsive to a possible 'Cancel' by the user.
- Add additional 'Check' criteria like file size, file name, file type, etc.
- Recover well from FTP failures and restart from the point of failure.