One Star

Passing parameter Dynamically to file naming convention

HI,
files would be arriving on day to to day basis into UNIX directory, for example as mentioned below:
test.20160401,
test.20160402
if we are running job  for  20160401 then talend job should pick file test.20160401 if if we are running job  for  20160402  then talend job should pick file test.20160402.
so i want to pass time stamp as parameter to all files as extension for that job running date.
can you please help me how to achieve this task?
Thanks,
Bharath.K
5 REPLIES
Moderator

Re: Passing parameter Dynamically to file naming convention

Hi,
so i want to pass time stamp as parameter to all files as extension for that job running date.

Could you please elaborate your case with an example with expected output values?
 Here is a component tFileProperties which obtains information about the main properties of a defined file.
Best regards
Sabrina 
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Passing parameter Dynamically to file naming convention

Hi,
Below is the example for my requirement:
Below is the source file name present in the job(extension-timestamp(YYYYMMDD) should be appended with file)
Sourc file Name: sales.YYYYMMDD
if we running job on April 14 2016 then our job looks file name as sales.20160414 in the directory
if we running job on April 20 2016 then our job looks file name as sales.20160420 in the directory
so whenever we running job how to pass dynamically timestamp as parameter to file name as extension?
Thanks,
Bharath.K
Nine Stars

Re: Passing parameter Dynamically to file naming convention

Are you running your job at the end of the work day?
String.valueOf(  TalendDate.getDate("yyyyMMdd") );
If you need to wait for the day to be over and calculate yesterday's date to process the sales from yesterday it would look like this:
String.valueOf(  TalendDate.addDate(TalendDate.getDate("yyyyMMdd"), "yyyyMMdd",-1,"DD")  )  );
One Star

Re: Passing parameter Dynamically to file naming convention

no, we are running job every day, but i want to pass file name dynamically insted of hard code name in the jobs.
how we can implement this?
Fifteen Stars

Re: Passing parameter Dynamically to file naming convention

Use a context variable or a globalMap variable for the filename. The context variable or globalMap variable will need to be set in a subjob prior to the one where the variable is being used to open the file.
Rilhia Solutions