So, I figure once I get a list of these files, I can just use tFileDelete to delete them. (I assume I would feed into tFileList and then make a connection to tFileDelete, like in the pic, but I'm not positive.)
What I don't know is how to read a directory and get a list of the (zip) files that are older that today minus x # of days.
Hi,I have reproduce the problem. This is cause by 60*60*24*1000*25 out of scope of Integer type(result is: -2134967296) So the result alway false Solution:change 60*60*24*1000*25 ---to---> 60*60*24*1000*25L(result is: 2160000000) Change the result is long type.
Dear All,
I am trying to delete file which are 100 days old , I have used same approach which is mentioned in below email but I AM UNABLE TO UNDERSTAND FOLLOWING THINGS.
STEPS:
1) please check my log files which are in format of: (Name of the JOB_currentdate_time)
Example:==> Log_InsertDIMItems_2014-07-11-13-27-18
This file i have created on Friday 11th July
I want to delete files which are older than 100 days.
2) Screenshot of my job:
3) Code in tFilter Component: Advance Code:
(TalendDate.getCurrentDate().getTime()-(File_prop.mtime+86400000*24))>0
By using this query(24 days limit) then 0 files are deleted , but by using 25 all files are getting deleted which is confusing for me. Please advise where I am wrong ?
I am not getting how this is happening.
Can anyone please guide me on same.
My requirement is of deleting files which are 1oo days old .
Thanks and Regards
RSH
Hi RSH, tFileList-->tFileProperties-->tJavaRow-->tFileDelete Use this flow, assign file names to context variables in tJavaRow based on your date condition and use that context variable in tFileDelete component for file to delete.. try this vaibhav
Hi vaibhav,
Thank you for reply.
Its not possible to declare context for each file because we have near about 30 different names of files. Is there any possibility to manipulate on current snapshot which i provided?
I am not getting where I made mistake ?
Regards
RSH
Hi,
mtime is unix timestamp in millisecond.. 86400000 represents one day
TalendDate.getCurrentDate().getTime()-86400000*2) - (input_row.mtime)>0
Above code deletes file which are older than two days.. you replace 2 by 100, then it should do the job... use wherever required in your design...
Try this.
vaibhav
Hi Vaibhav,
I used the query which you suggested, but still strange result.
All files from server got deleted
Not sure how this is working out:
Query:
(TalendDate.getCurrentDate().getTime()-86400000*100) - (File_prop.mtime)>0
can you try below code. it will help you on this issue. use this code in If condition.
new Date(File_prop.mtime).before(TalendDate.addDate(TalendDate.getCurrentDate(), -44, "dd"))==true
you can convert File_prop.mtime date into Date format using new Date(File_prop.mtime) constructor then you can add or minus days from date and compare with current date .