Five Stars

How to get file name from tfilelist

How to get file names, size, row count and send it to email by using Java components or can we achieve without java components

16 REPLIES
Fifteen Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

You can use the tFileProperties for everything but number of rows. For number of rows you will need to read the files and count them.

Rilhia Solutions
Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Actually my requirement is I have some set of different files in one (reject files)folder. I have to sent an email like filename, filesize and no.of records in file. Can you help me with this requirement.

Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Use 'tFileProperties' component to get the file name, size, permission, etc.

 

And to get the number of rows from file use 'tFileRowCount' component and link this using onSubJobOk to tJava/ tJavaRowcomponent. In tJava/ tJavaRow component use below expression to get the row count and store it into a context variable.

context.FILES_RECORDS = ((Integer)globalMap.get("tFileRowCount_1_COUNT"));
Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

How to dispaly the properties from tfileproperties.

Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Here I'm trying to replicate the solutions. Below is the screenshot of the Job Design.job-1.JPG

 

At tFileRowCount:

job-3.JPG

 

 

 

 

 

 

 

At tJava_2: job-2.JPG

 

At tFileProperties:

job-4.JPG

 

At tJavaRow:

job-5.JPG

 

At tSendMail:

job-6.JPG

 

Try this and let me know if this will work for you.

Also, Give kudos if this work for you. Smiley Wink

Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

It is listing only latest file, but I want all the files.

Fifteen Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

You can use the method shown, but will have to use some basic Java String manipulation to build up the details you want for each file (the email message) and append to that for each file. You should be able to do that in the tJavaRow quite easily.

Rilhia Solutions
Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

I have to list all the file names in single email can you help me with that.

Fifteen Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Something like this (you will have to experiment with this and tweak it yourself).....

context.Message = context.Message+"File: "+input_row.basename+"\r\n"+ 
"File Path: "+input_row.abs_path+"\r\n"+
"File Size: "+input_row.size+"\r\n\r\n";

You then just use the context.Message in your send mail component.

Rilhia Solutions
Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

I want to append all the files and need to send email

Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

I want to append all the files and need to send email
Fifteen Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Have you tried reproducing the job that @vaibsVB suggested? If not, do that first. If so, replace the tJavaRow code with mine (after configuring a new context variable for Message) and see what you get.

Rilhia Solutions
Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

I got the solution thanks for support

Fifteen Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Can you tell us what you did so that others can benefit from this question in the future?

Rilhia Solutions
Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

I have followed the above one @vaibsVB's model and gave your context.email(message) in tjavarow it is working 

Five Stars

Re: How to get file name, size , rowcount from tfilelist and send to email

Sorry for reaching late.

 

@im_arod Glad part of my solution work for you.

@rhall_2_0 Thanks for giving inputs.

 

In order to get all files from the folder, I tried another approach try this if it works for you.

And also suggest improvements also.

 

j1.JPG

 

tFileList_3 and tFileProperties_2 settings are same as previous example.

At tIterateToFlow_1 here are the settings:

j2.JPG

 

At tDenormalize_1 here are the settings:

j3.JPG

Make note, in above Delimiter setting I purposefully kept the ", ".

 

And you will get desired output i.e. FileNames from the folder in list format. You can store this filename list into context and use in Mail Component.

 

Regards.