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

Hello
The tFileProperties component(under File-->Management family) can fit your need. With tFileProperties component, you can get the create time of the file.
Best regards

shong
Anonymous
Not applicable
Author

what version is that in? Cause, its not showing up for me in TOS 2.3.3r13892

Ah, ok, I see it for the Perl version, but I'm in Java...
Anonymous
Not applicable
Author

this bug topic (3545) seems to indicate that the java module is completed in 2.4.0RC1. are the fixes that are in 2.3.3 also in the latest 2.4.0 release? (RC2)

Guess I'm about to find out.
Anonymous
Not applicable
Author

ok, so... is there somewhere I can find documentation on tFileProperties? cause its not in the most recent documentation available here http://www.talend.com/resources/documentation.php
and its not available in the help linked from TOS : http://127.0.0.1:50949/help/nav/2_2
or can someone tell me how to use this thing? please!
Anonymous
Not applicable
Author

Hello
The tFileProperties component describes the properties of one file, include:
abs_path: the absolute path
dirname: the direcotry name
basename: the file name
mode_string: read or write
size: the size of file
mtime: the create time of file, return millisecond (long)
mtime_string: the create time of file, return a date (String)
Here is a simple scenario(see the screenshot)
Best regards
shong
0683p000009MCDQ.png 0683p000009MCHe.png 0683p000009MCHj.png
Anonymous
Not applicable
Author

ok... now I can't figure out how I can filter on mtime_string and return either abs_path or basename to tFileList or tFileDelete
I mean, I think I can do some of the filtering in something like tMap, but I don't know if thats the right way to do it
Anonymous
Not applicable
Author

Hello
ok... now I can't figure out how I can filter on mtime_string and return either abs_path or basename to tFileList or tFileDelete

Here is a Java example, Please see the screenshot.
 /**
* Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT
* represented by this <tt>Date</tt> object.
*
* @return the number of milliseconds since January 1, 1970, 00:00:00 GMT
* represented by this date.
*/
public long getTime() {
return getTimeImpl();
}

Best regards

shong
0683p000009MCCH.png 0683p000009MCHo.png 0683p000009MC7l.png 0683p000009MCHt.png 0683p000009MCHy.png
Anonymous
Not applicable
Author

So I tried this process like you said, and it works perfectly... that is, until I try to change the # of days to anything greater than 24
I tried a bunch of different days, and all the ones <=24 worked, and all the ones >24 caused all the files to be deleted
Picture Information
1. contents of the folder before I run the clean up process
2. process with tFilterRow set to delete files created before 25 days
3. results of running the process defined in #2, where all files are deleted (whether they meet the filter criteria or not : before 5/6/08)
2. process with tFilterRow set to delete files created before 24 days
3. results of running the process defined in #4, where only the appropriate files are deleted (any files before 5/7/08)
Note:
tFileOutputDelimited_2 creates out_orig.txt (a list of all the files found in tFileList_3)
tFileOutputDelimited_1 creates out.txt (a list of all the files deleted by tFileDelete_1)
tFileOutputDelimited_3 creates out_notdeleted.txt (a list of all the files rejected by tFilterRow_1)

I find it kind of odd that the advanced filter in tFilterRow_1 works where ### (in the quoted formula below) is <=24, but not greater...
((TalendDate.getCurrentDate().getTime()-(table1.mtime+86400000*###))>0

Anonymous
Not applicable
Author

Ok, I figured out how to get around the problem I posted above:
1. set ### (in the post above) to a context variable (ex: context.NumDays_Past)
2. set the Type of that context variable to Double
a. You could use Float or Long, in place of Double, here - they both worked for me
b. Don't use Integer or Short, they cause all the files in the folder to delete.
c. Don't use Big Integer, it causes an error (Exception in thread "main" java.lang.Error: Unresolved compilation problem: The operator * is undefined for the argument type(s) int, BigDecimal)

(TalendDate.getCurrentDate().getTime()-(86400000*context.NumDays_Past))>table1.mtime