65.9K
CodeProject is changing. Read more.
Home

FTP search of older files and delete them

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.50/5 (5 votes)

May 25, 2004

1 min read

viewsIcon

44682

downloadIcon

698

Mark all the files on an FTP site that are older than a specified time and delete if required.

Sample Image - Ftp_Clearer.jpg

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:

  1. The FTP library provided by http://www.enterprisedt.com/.
  2. 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 and ParseUnixDirLine is not my code.)

Usage

  1. To preconfigure your servers, add the server/user/password in the options.xml file.
  2. Start the program.
  3. Set the 'Time before now' value as required.
  4. Choose to "Check directories" if you want the date of the directories also to be checked.
  5. Enter any comma separated strings in "Ignore Dirs with substring" if you do not want to scan directories that contain the specified substring.
  6. Click Scan.

Known issues:

  1. The program runs in a single thread and it might seem dead while the FTP site is being scanned.
  2. 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

  1. Make the program multithreaded, and responsive to a possible 'Cancel' by the user.
  2. Add additional 'Check' criteria like file size, file name, file type, etc.
  3. Recover well from FTP failures and restart from the point of failure.