I am quite new to KNIME and can’t find a solution of how to change multiple file Names.
I get files with company code and date on a monthly basis. I need to add a company name to a file name from a list. Like in the example. How can I do it?
Final Result should look like that:
CSV writer has a variable tab which allows you to specifiy the path (including the name) of your output file. So you can use e.g. string manipulation variable node to create the specific path and filename.
I would suggest checking out some workflows on the hub on how to work with variables
This workflow is a template for changing filenames.
Look at this link for a method for reading full file paths and writing the changes.
@Violeta I’ve added a branch with a Value Lookup which will be useful if the two input tables aren’t in the same order.
@Violeta If this works for you could you please mark it solved?
Dear @rfeigel thanks for your help. I get the Files and Folder from List Files node. I adapted the workflow a bit to get the new file name, but the workflow is not complete. How do I overwrite the existing files name with the new files names in the folder now. Below my workflow. Thank you!
Its not a simple overwrite since the filenames aren’t the same. Let me think about it.
Dear @rfeigel I copied your workflow and it works! Thank you very much!
Your welcome. Glad I could help.
I think the best approach is to read and write these files to another folder with the changed name. In my opinion, modifying the source file name is dangerous as it can lead to data loss.
I would address this problem with an approach in which a CSV Read Node with a variable port receives the new filenames prepared by a looping mechanism.
From there, the data from each CSV would be used to write to a blank CSV file named with the new name, in a new location.
My workflow has a choice of whether to overwrite the original file or add a file with a new name.
Thanks for the suggestion. It seems there are multiple ways to change files names. But the above solution worked for my case.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.