Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Hi
i have created new file and run the job,
If i used this expression ((TalendDate.getCurrentDate()).getTime() - (Long)row1.mtime) > (2 * 24 * 3600000) files are not deleting.
For this expression ((TalendDate.getCurrentDate()).getTime() - (Long)row1.mtime)+86400000 > (31* 24 * 3600000) all files are deleting at once. I found this while searching for the suitable expression it will delete before 31 days old files but deleting all.
Thanks,
Prasanth
I had to replace the math with:
Long.valueOf(2) * Long.valueOf(24) * Long.valueOf(3600000)
As the int values kept going negative due to size.
Hello @Shicong Hong ,
1] Delete files older than 48 hrs
condition in tMap - > ((TalendDate.getCurrentDate()).getTime() - (Long)row1.mtime) > (2 * 24 * 3600000)
2] The file name of tFileDelete component should be:
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
Thanks for the solution this works for me!