Add: script to replace backslashes
This commit is contained in:
parent
f00767fadf
commit
37aeb66d99
1 changed files with 22 additions and 0 deletions
22
PythonScripts/rename_backslash.py
Normal file
22
PythonScripts/rename_backslash.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def replace_backslash(directory):
|
||||||
|
for root, _, files in os.walk(directory):
|
||||||
|
for filename in files:
|
||||||
|
if "\\" in filename:
|
||||||
|
file_path = os.path.join(root, filename)
|
||||||
|
new_filename = filename.replace("\\", "⧹")
|
||||||
|
new_file_path = os.path.join(root, new_filename)
|
||||||
|
os.rename(file_path, new_file_path)
|
||||||
|
print(f"Renamed {file_path} to {new_file_path}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: python script_name.py <directory_path>")
|
||||||
|
else:
|
||||||
|
directory_path = sys.argv[1]
|
||||||
|
if not os.path.exists(directory_path):
|
||||||
|
print("Directory not found.")
|
||||||
|
else:
|
||||||
|
replace_backslash(directory_path)
|
Loading…
Reference in a new issue