Use File Processor Connector to delete files from an FTP or SFTP server. You can use the FTP_DELETE and SFTP_DELETE objects to delete files from an FTP or SFTP server.
You can delete all files from a folder, delete specific files from a folder, or delete specific files using the File_Path field.
•To delete all the files from a folder, specify the folder path in the Source File Directory connection property. Also, in the Select File connection property, select All. You do not need to filter by the File_Path field when you create a mapping.
•To delete only specific files from a folder, specify the folder path in the Source File Directory connection property. Also, in the Select File connection property, you can select options such as FileExtension, Startswith, Endswith, or Contains, based on your requirements. You do not need to filter by the File_Path field when you create a mapping.
•To delete files that are present in the FTP or SFTP server location, but do not list in the Select File property dropdown in the File Processor connection, you must specify the path of the files that you want to delete in a file in the Secure Agent location.
In the mapping, you can filter by the File_Path field. You must specify the absolute path of the file that stores the path of the files in the File_path field.
Note: If there are multiple files in the file that stores the path of the files and even if one file is not present in the specified location, the SFTP delete operation fails to delete that file and the successive files. In this case, the task retries the delete operation based on the retry count value that you specified in the advanced properties of the mapping. However, if there are multiple files in the file that stores the path of the files and if one file is not present in the specified location, the FTP delete operation deletes all the other files that are present in the specified location.
Deleting Files from an FTP Server Example
You are a system administrator and want to delete files from an FTP server. You can use the File_Path or LastModDate filter field to delete files from an FTP server.
Perform the following steps to create a synchronization task to delete files from the FTP server:
1In Data Integration, click New > Tasks.
2Select Synchronization Tasks, and click Create to create a synchronization task.
The Definition tab appears.
3Configure the following fields on the Definition tab:
Field
Description
Task Name
Name of the synchronization task. For example, FTP_DELETE_01.
Description
Description of the synchronization task. Maximum length is 255 characters.
Task Operation
Select Insert.
4Click Next.
The Source tab appears.
5Configure the following fields on the Source tab:
Field
Description
Connection
Select the connection you created. For example, FP_FTP_DELETE.
Source Type
Select Single.
Source Object
Select FTP_DELETE.
6Click Next.
The Target tab appears.
7Configure the following fields on the Target tab:
Field
Description
Connection
Select the flat file connection.
Target Object
Click Create Target.
8Click Next.
The Data Filters tab appears.
9Create a new filter and filter by the LastModDate or File_Path field on the Data Filters page.
Note: If you do not filter by the LastModDate or File_Path field, the Secure Agent deletes all the files in the source file directory.
- If you filter by LastModDate, specify the FTP_Hostname, FTP_User_ID, FTP_Password, and LastModDate fields as shown in the following image:
- If you filter by File_Path, specify the FTP_Hostname, FTP_User_ID, FTP_Password, and File_Path fields as shown in the following image:
Note: You must specify the Source File Directory, and the FTP_Password value as the PassKey1 in the connection.
10Click Next.
The Field Mapping tab appears.
11Click Automatch on the Field Mapping tab to map source fields to target fields accordingly.
12Click Validate Mapping to validate the mapping.
13Click Save and then Finish.
14From the Explore page, select the task, and click Actions > Run.
In Monitor, you can monitor the status of the logs after you run the task.