One Star

Iterating file in FTP directories using tLoop

Hi all,
Im a newbie in Talend Open Studio.
I want to iterate all files in the numbers of FTP directories, about more than 500 directories, then process those all files with another subjob. The name of directories are defined and set as global variable as array.
Here my SubJob :
tFTPConnection---On Subjob Ok-->tSetGlobalVar---On Subjob Ok-->tJava_1---On Sunjob Ok-->tLoop--iterate--->tFTPFilelist--iterate-->tJava_2
my Setting
1. tSetGlobalVar:
key=dir, value=new java.util.ArrayList<String>()
2. tJava_1
List<String> dir = (List<String>)globalMap.get("dir");
3. tLoop
for , from=0,to=((List<String>)globalMap.get("dir")).size()-1,step=1
4. tFTPFilelist
remote dir= "/shped/"+((List<String>)globalMap.get("dir")).get(((Integer)globalMap.get("tLoop_1_CURRENT_VALUE")))
5. tJava_2 to check the list of files
Problem :
- iteration only work at first directory, and stop execution with error in the next directory, this is error message:
Exception in component tFTPFileList_1
2: No such file
at com.jcraft.jsch.ChannelSftp.throwStatusError(
at com.jcraft.jsch.ChannelSftp._stat(
at com.jcraft.jsch.ChannelSftp._stat(
at shped.test3_0_1.test3.tLoop_1Process(
at shped.test3_0_1.test3.tJava_1Process(
at shped.test3_0_1.test3.tSetGlobalVar_1Process(
at shped.test3_0_1.test3.tFTPConnection_1Process(
Anything wrong? How then I can recovered this?
Community Manager

Re: Iterating file in FTP directories using tLoop

tForeach component is the best component to complete your request, you can use tForeach to replace tSetglobalvar tjava tloop components in the job, please read its user manual on Talend Help Center.
Talend | Data Agility for Modern Business