rename_count = 0
for src, dst in tqdm(filename_mappings, desc="Renaming Faces"):
if src == dst:
logger.debug("Skipping rename of "%s" as destination name is same as souce", src)
continue
old = os.path.join(self._faces.folder, src)
new = os.path.join(self._faces.folder, dst)
if os.path.exists(new):
// This should never happen, but is a safety measure to prevent deletion of faces
// when multiple files have the same hash.
logger.debug("Skipping renaming to an existing file: (src: "%s", dst: "%s"",
src, dst)
continue
logger.verbose("Renaming "%s" to "%s"", old, new)
os.rename(old, new)
rename_count += 1
return rename_count