delete all files in a folder at FTP using ftp batch script

user1153798 picture user1153798 · Feb 22, 2012 · Viewed 36.3k times · Source

Have batch script as follows:

>>ftp.txt open ftp.site.com
>>ftp.txt username
>>ftp.txt password
>>ftp.txt directoryname
>>ftp.txt quit
ftp -s ftp.txt

How can I delete all files in folder 'directoryname'?

Answer

Jim picture Jim · Feb 24, 2012

Put the following commands in ftp.txt and run as follows to accomplish this task:
ftp -i -s:ftp.txt

contents of ftp.txt:

open ftp.site.com
username
password
cd directoryname
mdelete *
quit