If you’re dead set on finding a way to do a recursive delete with Windows’ standard command line FTP client you’re in the wrong place. Actually, the whole internet is the wrong place for you. Why? It’s simply impossible to find a way to do recursive deleting of directories in ftp.exe on the Internet. Well, I’ve searched high and low and couldn’t find it that is. If you can, I’d love to hear from you.
What I did find however is a way to achieve the same thing with a simple different FTP client.
At my job someone was looking for a way to delete all contents from a certain directory. This directory contains files and more directories (which in turn can contain more files and even more directories). This is easy if you’re working in a graphical FTP client like FileZilla but in our case it had to be done with a script. This meant we needed to work from the command line. Windows’ standard FTP client simply didn’t work. As long as a directory is not empty, it can’t be deleted. There are probably complicated scripts that can be written to do what we want but we’re no guru’s and we couldn’t find them by means of Google.
After a lot of searching we finally found our answer. I knew that the linux based FTP client LFTP does what we want with a built in command. All I had to was find a way to run it in Windows. Finally Google was my friend again. It didn’t take too long for me to find a windows version of LFTP. It’s in a ZIP file and it can be downloaded from here.
When running the included install.bat, Windows complained a little but that didnÂ´t stop the program from working. I did need to specify the full path to the exe (for instance C:\Windows\lftp.exe) in order to run it. Now you could write a script like this:
debug 10 open ftp.blah.org user <user> <pass> rm -r <directory>
And after saving the script you can start LFTP like so:
C:\Windows\lftp.exe -f <script_file>
I assume you’ll understand that you’ll need to replace all text that is enclosed <like this> with their corresponding values (so replace <user> with the username to connect with and <pass> with the user’s password)?
Please let me know in the comments if you’ve found other ways to achieve the same thing (perhaps with Windows’ standard FTP client?). Hope this helps!