From f0cc1db793b3e1b35ae62a04df666703beb10476 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 19 Apr 2023 15:41:43 -0500 Subject: [PATCH] Tweaked changeprefix.py to not rename dir component in paths This wasn't implemented correctly anyways, as it would need to recursively rename directories that may not exist. Things would also get a bit complicated if only some files in a directory were renamed. Doable, but not needed for our use case. For now just ignore any directory components. Though this may be worth changing if the source directory structure becomes more complicated in the future (maybe with a -r/--recursive flag?). --- scripts/changeprefix.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/changeprefix.py b/scripts/changeprefix.py index 51844c05..381a4568 100755 --- a/scripts/changeprefix.py +++ b/scripts/changeprefix.py @@ -107,7 +107,10 @@ def main(from_prefix, to_prefix, paths=[], *, elif no_renames: to_path = from_path else: - to_path, _ = changeprefix(from_prefix, to_prefix, from_path) + to_path = os.path.join( + os.path.dirname(from_path), + changeprefix(from_prefix, to_prefix, + os.path.basename(from_path))[0]) # rename contents changefile(from_prefix, to_prefix, from_path, to_path,