Skip to content

Commit 742d80f

Browse files
committed
Add consistent output style and summary statistics
- Use → arrow for consistency with rename_invoices.py - Add renamed/skipped counters - Display summary at end of execution
1 parent db1c7ae commit 742d80f

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

python/rename_epubs.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ def main(folder: Path, dry_run: bool):
6868
click.echo("No epub files found.")
6969
return
7070

71+
renamed_count = 0
72+
skipped_count = 0
73+
7174
for epub_path in epubs:
7275
author, title = extract_metadata(epub_path)
7376

7477
if not author or not title:
7578
click.echo(f"Skipping {epub_path.name}: missing metadata")
79+
skipped_count += 1
7680
continue
7781

7882
new_name = sanitize_filename(f"{author} - {title}.epub")
@@ -83,10 +87,18 @@ def main(folder: Path, dry_run: bool):
8387
continue
8488

8589
if dry_run:
86-
click.echo(f"Would rename: {epub_path.name} -> {new_name}")
90+
click.echo(f"Would rename: {epub_path.name} {new_name}")
8791
else:
8892
epub_path.rename(new_path)
89-
click.echo(f"Renamed: {epub_path.name} -> {new_name}")
93+
click.echo(f"Renamed: {epub_path.name}{new_name}")
94+
renamed_count += 1
95+
96+
if renamed_count == 0 and skipped_count == 0:
97+
click.echo("\nNo files needed renaming.")
98+
elif dry_run:
99+
click.echo(f"\nDry run complete. {renamed_count} file(s) would be renamed, {skipped_count} skipped.")
100+
else:
101+
click.echo(f"\nRenamed {renamed_count} file(s), {skipped_count} skipped.")
90102

91103

92104
if __name__ == "__main__":

0 commit comments

Comments
 (0)