Talend - Rename File in Windows with a string retrieved by a tjava component

StackOverflow https://stackoverflow.com/questions/23115184

  •  04-07-2023
  •  | 
  •  

Question

Using Talend, I want to rename a file in a Windows machine with a filename that I don't know in advance retrieved from a field in a fixed length file. I intended to use the tFileCopy to do it, but I didn't know how to pass the field value from the tfileInputPositional to the tfileCopy component - Destination filename. So, I tried to rename the file exclusively with a java code routine executed with the tjava component. Nevertheless, after I successfully retrieved the name with the code routine I didn't manage to rename the file also with that code routine cause the file.renameTo method doesn't seem to work (known java issue).

So how from the tFileCopy component can I reference a value that I obtain running a tjava component? Is there any other way to pass a variable value to the tFileCopy component?

Was it helpful?

Solution

you can pass value from tfileInputPositional to tJavaRow (or your tJava) component and store the file name in a global var using

globalMap.put("filename","yourderivedfilename");

now in your tFileCopy component you can check RENAME option and give file name as

globalMap.get("filename")

and also you can check remove source file checkbox or use tFileDelete to remove old version of file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top