Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'?

like image 555
user1153798 Avatar asked Feb 22 '12 19:02

user1153798


People also ask

How do I delete a file from an FTP server in Linux?

To delete files on the FTP server use the delete command. To delete several files at once, use the mdelete command. You will be asked to provide a “y” or “n” confirmation for the deletion of each file. Here our FTP user has listed the files to see their names and then chosen one to delete.

How do I delete a folder in FTP?

FTP command line window instructionsUse the lrmdir command to remove an empty directory from your PC and the rmdir/xrmdir command (from the command line window only) to remove an empty directory from the FTP server.

How do I delete multiple files in Linux without prompt?

Using the -r flag to deleting a non-empty directory. If you do not want a prompt before deleting the directory and its contents, use the -rf flag. This will remove everything inside the directory, including the directory itself, without any confirmation.


1 Answers

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
like image 96
Jim Avatar answered Oct 16 '22 14:10

Jim