AutoIt
AutoIt
Delete Files Matching Pattern
See more FTP Examples
The DeleteMatching method deletes all files in the current remote directory matching a wildcarded filename.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oFtp = ObjCreate("Chilkat.Ftp2")
$oFtp.Hostname = "www.chilkatsoft.com"
$oFtp.Username = "MyLogin"
$oFtp.Password = "MyPassword"
; Connect and login to the FTP server.
$bSuccess = $oFtp.Connect()
If ($bSuccess <> True) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf
; Change to the remote directory where the files to be deleted are located.
; for the FTP account.
$bSuccess = $oFtp.ChangeRemoteDir("junk")
If ($bSuccess <> True) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf
; Delete all files with filenames matching "ftp_*.asp"
Local $iNumDeleted = $oFtp.DeleteMatching("ftp_*.asp")
If ($iNumDeleted < 0) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oFtp.Disconnect()
ConsoleWrite($iNumDeleted & " Files Deleted!" & @CRLF)