You have file created date in “FileDate” variable, and the date from which you want to delete all the files, stored in “OldDate” variable.
Step 6: Create output link in tMap, and name as “DeleteFlow”. then drag and drop all the source columns to this output. use below code into the abs_path column.
We are doing assigning file name and path to the context variable FilePathWithName.
Step 7: Click on “Filter Expression” button on output link, and add below code in it.
this code will check file created whether it is older than OldDate variable or not if yes then it will be pass to the next component for delete.
Final tMap_1 Setting looks like below image.
Step 8: Add tFileDelete component and connect with tMap using “deleteFlow”, then set the file Name = context.FilePathWithName context variable.
Step 9: Go to the context, click on "Ndays" variable and assign default value=30 (that is 30 days). save the job and execute.
You will see only one file deleted because today`s date is "13-03-2015" if we minus -30 days from today`s date we will get "11-2-2015" so we have only one file which is older than "11-2-2015".
you can add N number of days from day 1 to 360 or more. depends on your criteria how older files you want to delete.
I am Software consultant with approx 7 years of experience mainly in Business Intelligence and data warehousing assignments using Talend.
Writing is not my passion but i am doing it to help others. if you have any special case where you want me to demonstrate then please post me.