Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to iterate through multiple files all present in a single directory, get each of their filenames change the name accordingly and once the rename & copy operation is a success would like to remove the original file.
The current process is able rename all the files as per the criteria but when the option is chosen to "Remove Source File" the process is getting error-ed out.
The process will be copying the new files in the same directory as the source file is present.
Expression used in tMap to derive the filename -
row1.fileName.substring(0,StringHandling.INDEX(row1.fileName,"."))+"_"+TalendDate.formatDate("MMddyyyy",TalendDate.getCurrentDate())+row1.fileName.substring(StringHandling.INDEX(row1.fileName,"."),row1.fileName.length())
Job screenshot -
Am I following the correct approach in here or is there something that needs to be changed. Thanks in advance.
Platform: Talend Open Studio for Data Integration Version: 6.5.1
@TRF Thanks a ton for the suggestion. I definitely went overboard with my approach.
The expression suggested by you was having a minute problem with the extension so just made a little tweak to the expression for the destination file name -
((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(0,StringHandling.INDEX(((String)globalMap.get("tFileList_1_CURRENT_FILE")),"."))+"_"+TalendDate.formatDate("MMddyyyy",TalendDate.getCurrentDate())+((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(StringHandling.INDEX(((String)globalMap.get("tFileList_1_CURRENT_FILE")),"."),((String)globalMap.get("tFileList_1_CURRENT_FILE")).length())
Thank's for the feddback and sorry for the mistake, I answered from my mobile...
Here is the correct syntax:
((String)globalMap.get("tFileList_1_CURRENT_FILE")) .replace("." + ((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION")), "_" + TalendDate.formatDate("MMddyyyy", TalendDate.getCurrentDate()) +
"." + ((String)globalMap.get("tFileList_1_CURRENT_FILEEXTENSION")))
No problem @TRF.
This one works like a charm
Hi
I have multiple folder structures with same file name in each folders , when I am using tFileCopy it is taking only loading unique file name to the destination and excluding the rest. I would like to rename the the file with its sub folder name associated with it so that each file will have unique name , Can you please guide ,how will execute this .
* Renaming with date and extension is not working in this case .