Update idxtool.py

fixed rename count
This commit is contained in:
Elias Bachaalany 2023-12-27 15:57:54 -08:00
parent 5faa355643
commit 0e3570af9a

View file

@ -21,8 +21,7 @@ def get_toc_file() -> str:
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', TOC_FILENAME)) return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', TOC_FILENAME))
def rename_gpts(): def rename_gpts():
nb_ok = nb_total = 0 effective_rename = nb_ok = nb_total = 0
all_renamed_already = True
for ok, gpt in enum_gpts(): for ok, gpt in enum_gpts():
nb_total += 1 nb_total += 1
@ -34,7 +33,7 @@ def rename_gpts():
if basename.startswith(f"{id.id}_"): if basename.startswith(f"{id.id}_"):
nb_ok += 1 nb_ok += 1
continue continue
all_renamed_already = False effective_rename += 1
# New full file name with ID prefix # New full file name with ID prefix
new_fn = os.path.join(os.path.dirname(gpt.filename), f"{id.id}_{basename}") new_fn = os.path.join(os.path.dirname(gpt.filename), f"{id.id}_{basename}")
@ -53,7 +52,7 @@ def rename_gpts():
msg = f"Renamed {nb_ok} out of {nb_total} GPT files." msg = f"Renamed {nb_ok} out of {nb_total} GPT files."
ok = nb_ok == nb_total ok = nb_ok == nb_total
if all_renamed_already: if effective_rename == 0:
msg = f"All {nb_total} GPT files were already renamed. No action taken." msg = f"All {nb_total} GPT files were already renamed. No action taken."
print(msg) print(msg)