Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
prasanthkesana
Contributor
Contributor

How to delete files older than 48 hours

Hi

I have a requirement to delete old files based on date timestamp,

I found the component tFileProperties to fetch file properties

below is the sample job i have created by using the talend components

tFileList---iterate-- > tFileProperties ---main--->tMap-------main--->tfileDelte

On tMap schema editor i have used condition to check mtime in expression

((TalendDate.getCurrentDate()).getTime() - (Long)row1.mtime) > (8 * 24 * 3600000) to delete files based on above condition.

Can you please suggest any solution as per my requirement.

Thanks,

Prasanth

Labels (2)
12 Replies
Anonymous
Not applicable

Hi

 

What is the problem with your current job design? Is the file deleted?

 

Regards

Shong

 

 

 

 

 

 

 

prasanthkesana
Contributor
Contributor
Author

No, Job is running successfully but not deleting files based on condition. I'm not sure about the condition which i have applied.

Anonymous
Not applicable

if you just want to delete the files older than 48 hours, change the expression to

((TalendDate.getCurrentDate()).getTime() - (Long)row1.mtime) > (2 * 24 * 3600000)

 

prasanthkesana
Contributor
Contributor
Author

Hi Shong I have tried the above condition already but not working.

Is there any issue in the work flow of my job?

Below is the attached schema for tMap.

please suggest me any other alternative solution.

 

 

 

Thanks Prasanth

 

 

 

 

 

 

Anonymous
Not applicable

Hi

The file name of tFileDelete component should be:

((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))

Can you check it?

 

 

 

 

 

 

 

prasanthkesana
Contributor
Contributor
Author

Hi

It was not configured, but now i have added it in file name of tFileDelete and tested still not working.

Anonymous
Not applicable

I have tested your work flow and I am sure it works. Any error do you have? Try to output the filename on tMap to check if the filter condition is working.

0693p000009IlAHAA0.png

 

 

prasanthkesana
Contributor
Contributor
Author

Hi,

I have tested the work flow now all files are deleting even the condition is set to before 2 days files has to be delete from current date .

Anonymous
Not applicable

Just create a new file for testing, if the new file is deleted also, there must be something wrong in your job.