One Star

write file names in a folder to a file

The scenario is that I've got a folder which may contain sub folder and files. Then I want to have these files info (like created date, size, file name, file abs path and so on) and write them to another file.
I can iterate the file list by using tFileList and get the properties by tFileProperties. Then I'll link the tFileProperties to tOutputExcel. But the problem is that the excel file will only write down the last file info. Could anyone give some clue that how to make a loop to take every file's info to a different file?
5 REPLIES
One Star

Re: write file names in a folder to a file

Hi,
On your tfileoutputexcel, check the 'append exisitng file' and 'append existing sheet' options. This will give you a list of file/props.
HTH
Seven Stars

Re: write file names in a folder to a file

You can also put a tUnite before your tFileOutputExcel to combine the data from each iteration into one flow before it's written.

Re: write file names in a folder to a file

Hi,
I would like to know how we can do this. I have the similar functionality.
Can you please attach the screen shot of your job.
Thanks & Regards,
Syed
One Star

Re: write file names in a folder to a file

Hi;
This is an easy example to get the file properties;
In the first step you have just to drag and drop the components from the palette and link them as follow.
tFileList--iterate-->tFileProperties-->main(out)-->tfileOutputDelimited.
In the seconde step you must set the component's propreties in order to work fine as follow:
1: tFileList->folder= "your folder"
2: tFileProperties->file= ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
3: in order to get the information in the output file you must de synchronize the schema and check the option ?append existing file?, and include the name of columns
You can now run the job and it?ll run fine
good luck
One Star

Re: write file names in a folder to a file

It's working now! Thanks everyone!