Hello everybody, is there a ways to rename a opened file?
Background:
On windows you could do a “rename a.exe b.exe” and after every connection to this files is closed the renaming is done. With files transfer node this is not possible, as this node is only able to delete the sourcefile after successfull copy, i guess.
Howto:
Is is maybe possible to rename a file on a connected filesystem(smb) with java snippet?
BG Karsten
import os
with open("example.txt", "r") as file:
# Read the contents of the file
contents = file.read()
# Rename the file
os.rename("example.txt", "new_example.txt")
# Open the renamed file
with open("new_example.txt", "w") as file:
# Write some text to the file
file.write("This is the new file.")
# The file is automatically closed when the context manager exits
[WinError 2] system can not find the file: ‘test.txt’ → ‘new_example.txt’
Traceback (most recent call last):
File “”, line 5, in
FileNotFoundError: [WinError 2] System can not find the file: ‘test.txt’ → ‘new_example.txt’
If i do this with full path (not the connected fily system) it works.
Does thy python node in Knime >= 4.7 have a filesystem port or something similar?