mirror of
https://github.com/kevinveenbirkenbach/bulk-string-replacer.git
synced 2024-11-01 01:53:11 +01:00
Solved bug
This commit is contained in:
parent
df49d43c50
commit
75cdf367b2
@ -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(".")]
|
dirs[:] = [d for d in dirs if not d.startswith(".")]
|
||||||
filenames = [f for f in filenames if not f.startswith(".")]
|
filenames = [f for f in filenames if not f.startswith(".")]
|
||||||
|
|
||||||
if folder:
|
if content:
|
||||||
for d in dirs:
|
for f in filenames:
|
||||||
if old_string in d:
|
replace_content(os.path.join(root, f), old_string, new_string, preview, verbose)
|
||||||
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 files:
|
if files:
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
@ -42,9 +36,15 @@ def process_directory(base_path, old_string, new_string, recursive, folder, file
|
|||||||
if not preview:
|
if not preview:
|
||||||
os.rename(old_path, new_path)
|
os.rename(old_path, new_path)
|
||||||
|
|
||||||
if content:
|
if folder:
|
||||||
for f in filenames:
|
for d in dirs:
|
||||||
replace_content(os.path.join(root, f), old_string, new_string, preview, verbose)
|
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:
|
if not recursive:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user