diff -u -r wget-1.6.orig/src/ftp.c wget-1.6/src/ftp.c
--- wget-1.6.orig/src/ftp.c	Sun Dec 31 12:47:33 2000
+++ wget-1.6/src/ftp.c	Sat Mar 17 14:20:20 2001
@@ -37,6 +37,8 @@
 # include <netdb.h>		/* for h_errno */
 #endif
 
+#include <dirent.h>
+
 #include "wget.h"
 #include "utils.h"
 #include "url.h"
@@ -1312,7 +1314,6 @@
   for (; f; f = f->next)
     {
       int len;
-
       if (downloaded_exceeds_quota ())
 	break;
       if (f->type != FT_DIRECTORY)
@@ -1348,6 +1349,39 @@
 }
 
 
+static void
+unlink_recursive(char *path)
+{
+  struct stat st;
+
+  if (stat(path, &st) != 0) {
+    logprintf (LOG_NOTQUIET, "stat: %s: %s\n", path, strerror(errno));
+    return;
+  }
+  if (S_ISDIR(st.st_mode)) {
+    DIR *dir;
+    struct dirent *dirent;
+    if ((dir = opendir(path)) != NULL) {
+      while (dirent = readdir(dir)) {
+	char *fname;
+	if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0)
+	  continue;
+	fname = xmalloc(strlen(path)+1+strlen(dirent->d_name)+1);
+	sprintf(fname, "%s/%s", path, dirent->d_name);
+	unlink_recursive(fname);
+	free(fname);
+      }
+      closedir(dir);
+      if (rmdir(path) != 0)
+	logprintf (LOG_NOTQUIET, "rmdir: %s: %s\n", path, strerror(errno));
+    }
+  } else {
+    if (unlink(path) != 0)
+      logprintf (LOG_NOTQUIET, "unlink: %s: %s\n", path, strerror(errno));
+  }
+}
+
+
 /* A near-top-level function to retrieve the files in a directory.
    The function calls ftp_get_listing, to get a linked list of files.
    Then it weeds out the file names that do not match the pattern.
@@ -1366,6 +1400,62 @@
 
   orig = ftp_get_listing (u, con);
   start = orig;
+
+  /* Delete file if only exist on local */
+  if (opt.delete_local && opt.recursive)
+    {
+      struct fileinfo *f;
+      char *olocal, *ofile;
+      char *dir;
+      int i;
+      DIR *d;
+      struct dirent *dirent;
+
+      olocal = u->local;
+      ofile = u->file;
+      u->file = ".";
+      u->local = url_filename(u);
+      dir = u->local;
+
+      for (i=strlen(dir)-1; i>=0 && dir[i]!='/'; i--)
+	{
+	  dir[i] = '\0';
+	}
+
+      if ((d = opendir(dir)) != NULL)
+	{
+	  while (dirent = readdir(d))
+	    {
+	      char *fname = dirent->d_name;
+	      if (fname[0] == '.')
+		continue;
+	      for (f=orig; f; f=f->next)
+		{
+		  if (strcmp(f->name, fname) == 0)
+		    break;
+		}
+	      if (!f)
+		{
+		  char *path;
+		  char *tms;
+
+		  tms = time_str(NULL);
+		  path = xmalloc(strlen(dir)+1+strlen(fname)+1);
+		  sprintf(path, "%s/%s", dir, fname);
+		  logprintf (LOG_NONVERBOSE, "%s delete local file \"%s\"\n",
+			     tms, path);
+		  unlink_recursive(path);
+		  free(path);
+		}
+	    }
+	  closedir(d);
+	}
+
+      free(dir);
+      u->local = olocal;
+      u->file = ofile;
+    }
+
   /* First: weed out that do not conform the global rules given in
      opt.accepts and opt.rejects.  */
   if (opt.accepts || opt.rejects)
diff -u -r wget-1.6.orig/src/init.c wget-1.6/src/init.c
--- wget-1.6.orig/src/init.c	Mon Dec 18 04:28:19 2000
+++ wget-1.6/src/init.c	Sat Mar 17 08:16:37 2001
@@ -105,6 +105,7 @@
   { "debug",		&opt.debug,		cmd_boolean },
 #endif
   { "deleteafter",	&opt.delete_after,	cmd_boolean },
+  { "deletelocal",	&opt.delete_local,	cmd_boolean },
   { "dirprefix",	&opt.dir_prefix,	cmd_string },
   { "dirstruct",	NULL,			cmd_spec_dirstruct },
   { "domains",		&opt.domains,		cmd_vector },
diff -u -r wget-1.6.orig/src/main.c wget-1.6/src/main.c
--- wget-1.6.orig/src/main.c	Sun Dec 31 13:05:18 2000
+++ wget-1.6/src/main.c	Sat Mar 17 08:22:54 2001
@@ -259,6 +259,7 @@
     { "cache", required_argument, NULL, 'C' },
     { "cut-dirs", required_argument, NULL, 17 },
     { "delete-after", no_argument, NULL, 8 },
+    { "delete-local", no_argument, NULL, 130 },
     { "directory-prefix", required_argument, NULL, 'P' },
     { "domains", required_argument, NULL, 'D' },
     { "dot-style", required_argument, NULL, 6 },
@@ -608,6 +609,10 @@
 	  setval ("useproxy", optarg);
 	  break;
 
+	case 130:
+	  setval ("deletelocal", "on");
+	  break;
+
 	case '?':
 	  print_usage ();
 	  printf ("\n");
diff -u -r wget-1.6.orig/src/options.h wget-1.6/src/options.h
--- wget-1.6.orig/src/options.h	Mon Dec 11 09:53:11 2000
+++ wget-1.6/src/options.h	Sat Mar 17 08:16:27 2001
@@ -152,6 +152,8 @@
 				   necessary to display a page properly. */
 
   struct sockaddr_in *bind_address; /* What local IP address to bind to. */
+
+  int delete_local;		/* Whether local file will be deleted if it does not exist on remote host */
 };
 
 #ifndef OPTIONS_DEFINED_HERE
