What is the FTP Command for deleting multiple files as once?

13

2

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?

F G

Posted 2012-03-08T15:44:26.363

Reputation: 155

Answers

27

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.

Canute Bigler

Posted 2012-03-08T15:44:26.363

Reputation: 386

As a side note, the MS command-line client also supports mput for putting multiple files up at a time (mput *.dll). – Lynn Crumbling – 2012-03-08T15:57:22.723

Thanks, it works fine!!! However if I write MDEL *.csv it asks the confirmation, I would do this automatically without confirmation, how could I do this? – None – 2012-03-08T16:09:36.477

I've not tested it, but you might try putting the mdel command (and possibly the "yes" response that mdel wants) inside a text file and then using the -s option to load the ftp commands from the file. – None – 2012-03-08T16:18:54.747

Thanks but where should I put the yes response? – None – 2012-03-08T16:23:54.567

4use prompt to switch interactive mode off before using mdel – MBu – 2012-03-08T16:32:59.083

So should I write something like "prompt mdel *.csv" ? – None – 2012-03-08T16:45:17.520

If you're working with ftp interactively, then the prompt and mdel commands would be entered separately. – None – 2012-03-08T17:12:25.540

3

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

Alan

Posted 2012-03-08T15:44:26.363

Reputation: 31

mdelete with prompts ftw. – justinpage – 2017-04-10T22:43:18.767

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

Alessandro

Posted 2012-03-08T15:44:26.363

Reputation: 11