Invalid cross-device link solved by substituting os.rename by shutil.move