Delete with wildcards from FTP server

Most FTP users use an FTP client to access their FTP server. While there may be a client that is capable of deleting files with wildcards, FileZilla Client does not. After a little research, there is a command available to Windows and Linux users accessible via command line. The command is simply called FTP.

Windows / Linux users
Aside from some minor differences in text, the following process has been tested to work on both a Microsoft Windows 7 and CentOS 5.8 operating system.

  • Go to the command prompt
  • Type ftp -i ftp.yourftpsite.com (using the -i turns off interactive prompting during mulpile file transfers)
  • At the welcome message, you will be prompted for username.
  • Press enter.
  • Type your password
  • Press enter.
  • A message indicating your location.

To navigate, use basic DOS commands like CD to change directory. Navigate to the desired directory. Then issue the command DIR to list contents, or something like DIR *150×150.jpg to list all JPGs with that wildcard and 150×150.jpg. To delete these using a wildcard, issue the command mdelete *150×150.jpg. This will multiple delete the wildcard with 150×150.jpg without prompting for confirmation. When done at the ftp prompt, type quit and enter and you are out of the FTP utility.

Another example, from a directory, where there are several files with the extension of .sql.gz that I want to delete.

ftp> mdelete *.sql.gz

The result is.

200 TYPE is now ASCII
250 Deleted Backup_01.01.12-01.01.01.e75ec0.sql.gz
250 Deleted Backup_01.02.12-01.01.01.938837.sql.gz
250 Deleted Backup_01.03.12-01.01.01.4sk834.sql.gz
250 Deleted Backup_01.05.12-01.01.01.3h8shh.sql.gz

Done.

This process to delete a sampling of 400 files mixed in with some 2200 files only took a few seconds. Originally, using the FileZilla Client, I was going through file by file, and manually highlighting and deleting. This is an extremely time consuming approach.