Skip to content

Commit f0cc1db

Browse files
committed
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?).
1 parent ba1c764 commit f0cc1db

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/changeprefix.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ def main(from_prefix, to_prefix, paths=[], *,
107107
elif no_renames:
108108
to_path = from_path
109109
else:
110-
to_path, _ = changeprefix(from_prefix, to_prefix, from_path)
110+
to_path = os.path.join(
111+
os.path.dirname(from_path),
112+
changeprefix(from_prefix, to_prefix,
113+
os.path.basename(from_path))[0])
111114

112115
# rename contents
113116
changefile(from_prefix, to_prefix, from_path, to_path,

0 commit comments

Comments
 (0)