Hi @tazar , you’re not really “renaming” the files, but actually opening the files, reading the content and writing the content to another file. This is quite slow.
And also, your original files still exist after this operation.
I would do the renaming via your OS rename command (ren for windows, mv for Linux/UNIX/MacOS), but I would build the command via Knime.
I’m guessing in your List of file names Excel file, you have an old_name column and a new_name column?
Just generate the OS commands like this:
join("ren ", $old_name$, " ", $new_name$)
join("mv ", $old_name$, " ", $new_name$)
And save this to a .bat file under Windows, or to a .sh file under Linux/UNIX/MacOS.
Then run the .bat or .sh file
EDIT: I put something simple together for you that looks like this:
My List of file names looks like this:
I’ll do the demo for Windows, so I use this:
And it generated these commands:
I filter out the other columns and keep the command column only as it’s what I want to write to the file.
I use a CSV Writer here. While there is a File Reader, there is no File Writer. A CSV file is just a text file, so we can use this to write any text file.
The CSV Writer should be configured like this:
Make sure you remove the quotes, and we don’t want to write the Header either.
This generates a file called rename_script.bat with the following commands:
ren file1.xlsx file01.xlsx
ren file2.xlsx file02.xlsx
ren file3.xlsx file3_bak.xlsx
Here’s the sample workflow: Rename files from another files.knwf (11.4 KB)