Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I have a directory where I put files every minute. I want this directory to delete the files which are there over 8 days. How is this possible?
Thanks a lot.
Using tFileProperties you can access the mtime field which represents the last modification date for the file.
Then you just have to compare with actual datetime to decide to delete the file or not.
Here is the design:
tFileList--(iterate)-->tFileProperties--(main)-->tFlowToIterate--(OnComponentOk)--(If)-->tFileDelete
And here is the condition for the "If" trigger:
((TalendDate.getCurrentDate()).getTime() - (Long)globalMap.get("row1.mtime")) > (8 * 24 * 3600000)
This suppose the flow after tFileProperties is called "row1".
If not, you just have to adjust the condition with the real flow name.
Using tFileProperties you can access the mtime field which represents the last modification date for the file.
Then you just have to compare with actual datetime to decide to delete the file or not.
Here is the design:
tFileList--(iterate)-->tFileProperties--(main)-->tFlowToIterate--(OnComponentOk)--(If)-->tFileDelete
And here is the condition for the "If" trigger:
((TalendDate.getCurrentDate()).getTime() - (Long)globalMap.get("row1.mtime")) > (8 * 24 * 3600000)
This suppose the flow after tFileProperties is called "row1".
If not, you just have to adjust the condition with the real flow name.
@TRF thank you a lot really.
I want to ask you also something if You know.
I create this CSV and I append this info inside :
pw.println(TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", TalendDate.getCurrentDate()) + " , " + "Error in reading file: " + ((String)globalMap.get("tWaitForFile_2_FILENAME")) + " , " + "Error: " + input_row.errorMessage);
In this case which is one file but I want to delete rows from the CSV after 8 days, how can I do it?