One Star

How to delete files in a tFileList iteration?

Hi
I have a scenario which must be very common.
I have a staging directory which I will automatically monitor for files.
When files are found (1 or more), I want to iterate through the found files, do some processing, and then move the processed file.
I am using a tFileList for the iteration.
My problem is that it seems impossible to do any operation that affects
the current file (tFileDelete or tFileCopy with "Remove source File" checked).
I get no errors, but the file is simply not deleted.

What is the best practice to remove processed files from the staging directory?

My env is TIS 2.4.1.r16077, I'm working in a Java project
Any advice appreciated
6 REPLIES
Community Manager

Re: How to delete files in a tFileList iteration?

Hello
the current file (tFileDelete or tFileCopy with "Remove source File" checked).

tFileList--iterate-->tFileDelete
In the file name field, press ctrl+blank space, then select the global variable: tFileList_current_file_path
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to delete files in a tFileList iteration?

Hi shong,
if after deletion i needed to do something without exiting from current iteration of tFileList, should it be possible to connect tFileDelete to a tRunJob?
I have tried whith a "main" connection, but it says "if this component has output, ther emust be an input link to propagate the data".
Which is silly , because i do not have any output.
What should i do?
One Star

Re: How to delete files in a tFileList iteration?

Hi,
onComponentOk should be the right connection.
Bye
Volker
One Star

Re: How to delete files in a tFileList iteration?

But, OnComponentOk is it still into the current TFileList iteration?
Does tFileList iteration wait for the subjob to be ended, if it is linked only with a onComponentOk ?
One Star

Re: How to delete files in a tFileList iteration?

Hi,
i thought about doing a branch. So you data flow (main) will go wherever it will be needed and onComponentOk will go to tFileDelete.
Will tFileDelete wait for tRunJob? Good question. I think onComponentOk is triggered after all actions of the components are done. And the last one is done at the end of the iteration. So it will wait for tRunJob.
Please correct me if I'm wrong.
Bye
Volker
One Star

Re: How to delete files in a tFileList iteration?

Hello,
I'm also running into the same issue with tFileDelete NOT deleting while no error returned.
Here's my flow, not sure if the order of the flow might be causing it not to Delete?

tFileList (iterate) --> tFileInputDelimited --> tMSSQLOutput --> tFileCopy --> tFileDelete (not deleting)
I can delete with a separate branch, but not sure why my flow above wouldn't delete? Any idea?

tFileList (iterate) --> tFileInputDelimited --> tMSSQLOutput --> tFileCopy
tFileList2 (iterate) --> tFileDelete2 (deleting)
However, if I use two separate branch, what do I need to do to call the second tFileList when the the first tFileList iteration actions are complete?
Your help is much appreciated!