How to change file name / extension for number of files?

Hello community Smiley Happy
I need your advice for the following problem:
I have a job that gets files from remote FTP server.
I need to archive these files and then change file names / extensions for originally downloaded files. (see job print screens)
Naming of source files is done according to the following mask: cccccc_yyyy-MM-dd.dat
I need to keep only first 6 characters and .dat should be changed to .csv
My idea was to use tFileCopy with Rename to change file name/extension. But it fails...
Looks like I can't use Talend StringHandling system routine to build destination filename
Like LEFT(((String)globalMap.get("tFileList_1_CURRENT_FILE")),6)+".csv"
The warning/error is:
Warning! Some errors exist in jobs.
The method LEFT(string, int) is undefined for the type get_files_from_ftp
Any idea how can I change file name / extension for number of downloaded files?
3 REPLIES
Community Manager

Re: How to change file name / extension for number of files?

Hello
The destination name should be:
StringHandling.LEFT(((String)globalMap.get("tFileList_1_CURRENT_FILE")),6)+".csv"

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: How to change file name / extension for number of files?

Thank you Shong. Now it works...
One Star

Re: How to change file name / extension for number of files?

hi shong!!!

Ur solution seem to solve my problem..
but i need to add the counting number in between in file name..
for example
StringHandling.LEFT(((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")),6)+ ".txt"
this returns as 'sample.txt'
but i want it as 'sample_001.txt'
001 should be the file count that retrieves per day..
Thank u so much!!!!