One Star

Check if multiple files exist

Hi,
Is someone able to explain to me what components to use and how I can do the following?
I have a table which references a path and filename of a collection of files location on a mapped network drive.
I want to be able to iterate through each row of the table, and then based on the path and filename, confirm that the file actually exists.
I've had a look at the tfileexist component but this does not seem to take a file path input.
Thanks,
Simon
3 REPLIES
Community Manager

Re: Check if multiple files exist

Hi Simon
tFileExist is the suitable component to check if the file exist or not, the job looks like:
tMysqlInput--row1--tFlowToIterate--iterate---tFileExist
Assuming that you query two fields from the table: filepath and filename
in the filename/stream field of tFileExist:
row1.filepath+"/"+row1.filename
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Check if multiple files exist

Thanks Shong.
1 more basic question. I now need the id, filename and a true / false (if exists) to be written to file.
How to I capture the result of the tfileexist component to output?
Thanks,
Simon
Community Manager

Re: Check if multiple files exist

Thanks Shong.
1 more basic question. I now need the id, filename and a true / false (if exists) to be written to file.
How to I capture the result of the tfileexist component to output?
Thanks,
Simon

Base on your request, the job looks like:
tMysqlInput--row1--tFlowToIterate--iterate---tFileExist_1--oncomponentok--tFixedFlowInput--main--tFileOutputDelimited
on tFixedFlowInput, add three columns on the schema: id, filename and isExist
columnName:value
idSmiley SadInteger)globalMap.get("row1.id")
filenameSmiley SadString)globalMap.get("row1.filename")
isExistSmiley Sad(Boolean)globalMap.get("tFileExist_1_EXISTS"))
on tFileOutputDelimited, check the box 'append'
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business