What Is the Ftp Command for Deleting Multiple Files as Once?

I'm trying to run this command via FTP in order to delete some files I have stored in a folder in my website:

DEL *.csv

However this doesn't work and I don't know why. However if I try to delete every single file this works:

DEL file.csv (works)

How could I do in order to solve this issue?

4 Answers

If you're using the Windows command-line ftp client, then you will need to use mdelete to delete multiple files, as delete will only delete a single file.

Edit: Answering the additional questions in the comments.

If you want to put these commands in a file so that you can perform them as some kind of batch process, you could create a text file and put the commands in sequence there:

prompt
mdel *
quit

Then you could run this as a single step with the -s parameter.

7

To use mdelete use the syntax below to automate the process

At the FTP> use the "prompt" command to disable interaction (mode off)

Type this command:

  • FTP> mdelete [directory] *.extenstion |yes

For example, mdelete standard *.jpg |yes

1

With Windows 7:

The existing answer will work only partially. To delete more files at once without confirmation from the server we must connect to the server with the command:

ftp -i yourwebsite

So after you connect with that command, you can use mdelete at the FTP prompt:

mdelete *.html

This is an example for an inline multidelete ftp script, added bonus an aritmetic YYYYMM variable. Use prompt to disable an interactive prompt query.

#!/bin/sh
## Delete files from FTP server

HOST=11.22.33.44
USER=myuser
PWD="mypwd"

YM=$(date +'%Y%m')
YM=$(( $YM-3 ))
echo YearMonth $YM

ftp -p -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PWD
prompt
mdel prefix${YM}*.zip
quit
END_SCRIPT
exit 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest