When I open a file in Python with f = open("filename.txt")
, I can access the filename using the name
property (file_object.name
). However, if that file is moved to another path, the name
property isn't updated.
I can detect that the file has moved by opening the file again, calling stat and comparing the inode, but I couldn't find a way to get the new name of the original file. Is this possible? If not in Python, is there a way in C? Posix? Linux?