Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

delete files more than 45 days (example) old?

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.
0683p000009MC31.jpg
Labels (2)
21 Replies
_AnonymousUser
Specialist III
Specialist III

Hi, I am having error to this context.NumDays_Past
nullpointerexception.
what values you put in context.NumDays_Past?
Regards.
Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

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
0683p000009MCII.jpg 0683p000009MC2i.jpg 0683p000009MCIN.png 0683p000009MCIS.jpg 0683p000009MCBO.jpg
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

If I use :
(TalendDate.getCurrentDate().getTime()-(File_prop.mtime+86400000*25))>0
All files are getting DELETED (--NOT SURE HOW)
Please find below is an snapshot of result:
mtime mtime_string GetDate Calculated_Data_OF_Advance_Filter
1,40508E+12 Fri Jul 11 13:27:20 CEST 2014 1,40533E+12 2390162346
1,40508E+12 Fri Jul 11 13:27:20 CEST 2014 1,40533E+12 2390162867
1,40508E+12 Fri Jul 11 13:27:19 CEST 2014 1,40533E+12 2390163079
1,40508E+12 Fri Jul 11 13:27:20 CEST 2014 1,40533E+12 2390162220
1,40508E+12 Fri Jul 11 13:27:20 CEST 2014 1,40533E+12 2390162663

If i use
(TalendDate.getCurrentDate().getTime()-(File_prop.mtime+86400000*24))>0
NO file is deleted..
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

Hi Vaibhav,
I used the query which you suggested, but still strange result.
All files from server got deleted 0683p000009MPcz.png
Not sure how this is working out:
Query:
(TalendDate.getCurrentDate().getTime()-86400000*100) - (File_prop.mtime)>0
Anonymous
Not applicable
Author

Hello ,
Can anyone please guide me on my issue please ?
Thanks in advance.
Regards
RSH
Anonymous
Not applicable
Author

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 .