diff --git a/renamebycsv/cli.py b/renamebycsv/cli.py index 1dc49a2..602c691 100755 --- a/renamebycsv/cli.py +++ b/renamebycsv/cli.py @@ -8,15 +8,16 @@ from renamebycsv.renamer import find_all_candidates, rename_by_csv def run(args): candidates = find_all_candidates(args.input_dir, args.pattern, args.recursive) - rename_by_csv( - args.csv, - candidates, - args.current, - args.become, - args.dry, - args.extension, - args.keep_extension, - ) + if len(candidates): + rename_by_csv( + args.csv, + candidates, + args.current, + args.become, + args.dry, + args.extension, + args.keep_extension, + ) def main(): diff --git a/renamebycsv/renamer.py b/renamebycsv/renamer.py index 542f288..3fc8548 100644 --- a/renamebycsv/renamer.py +++ b/renamebycsv/renamer.py @@ -32,6 +32,8 @@ def find_all_candidates(input_dir: str, regex: str, recursive: bool): regex, input_dir, ) + else: + logging.info("Collected %d files to rename.", len(results)) return results @@ -51,6 +53,10 @@ def rename_by_csv( become_col_ind = None for row in reader: if current_col_ind is None and become_col_ind is None: + if current not in row: + logging.error("\"%s\" not in header %s.", current, list(row)) + if become not in row: + logging.error("\"%s\" not in header %s.", become, list(row)) current_col_ind = row.index(current) become_col_ind = row.index(become) continue @@ -80,7 +86,7 @@ def rename_by_csv( logging.info(f'Will rename "{original}" to "{os.path.basename(objective)}"') if os.path.exists(objective): logging.error( - f'Path at "{objective}" exists, not continuing. ' + f'Path at "{objective}" already exists, not continuing. ' "Use -f to overwrite instead of stopping." ) exit(1) diff --git a/setup.cfg b/setup.cfg index d8e3b50..7585359 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = renamebycsv -version = 0.0.7 +version = 0.0.8 [options] packages = renamebycsv