Solved bug

This commit is contained in:
Kevin Veen-Birkenbach 2023-08-22 22:42:57 +02:00
parent df49d43c50
commit 75cdf367b2

View File

@ -22,15 +22,9 @@ def process_directory(base_path, old_string, new_string, recursive, folder, file
dirs[:] = [d for d in dirs if not d.startswith(".")]
filenames = [f for f in filenames if not f.startswith(".")]
if folder:
for d in dirs:
if old_string in d:
old_path = os.path.join(root, d)
new_path = os.path.join(root, d.replace(old_string, new_string))
if verbose:
print(f"Renaming directory from: {old_path} to: {new_path}")
if not preview:
os.rename(old_path, new_path)
if content:
for f in filenames:
replace_content(os.path.join(root, f), old_string, new_string, preview, verbose)
if files:
for f in filenames:
@ -42,9 +36,15 @@ def process_directory(base_path, old_string, new_string, recursive, folder, file
if not preview:
os.rename(old_path, new_path)
if content:
for f in filenames:
replace_content(os.path.join(root, f), old_string, new_string, preview, verbose)
if folder:
for d in dirs:
if old_string in d:
old_path = os.path.join(root, d)
new_path = os.path.join(root, d.replace(old_string, new_string))
if verbose:
print(f"Renaming directory from: {old_path} to: {new_path}")
if not preview:
os.rename(old_path, new_path)
if not recursive:
break