in an entire remote tree luckilythis was very easy to do given all the reuse that example - inherits from the ftptools superclass herewe just have to define the extension for recursive remote deletions even in tactical mode like thisoop can be decided advantage example - pp \internet\ftp\mirror\cleanall py #!/bin/env python ""#############################################################################extend the ftptools class to delete files and subdirectories from remote directory treesupports nested directories toodepends on the dir(command output formatwhich may vary on some serverssee python' tools\scripts\ftpmirror py for hintsextend me for remote tree downloads#############################################################################""from ftptools import ftptools class cleanall(ftptools)""delete an entire remote tree of subdirectories ""def __init__(self)self fcount self dcount def getlocaldir(self)return none irrelevent here def getcleanall(self)return true implied here def cleandir(self)""for each item in current remote directorydel simple filesrecur into and then del subdirectories the dir(ftp call passes each line to func or method ""lines [each level has own lines self connection dir(lines appendlist current remote dir for line in linesparsed line split(split on whitespace permiss parsed[ assume 'drw filenamefname parsed[- if fname in ('')some include cwd and parent continue elif permiss[ !' 'simple filedelete print('file'fnameself connection delete(fnameself fcount + elsedirectoryrecurdel print('directory'fname client-side scripting