initial commit: cleanup script + readme
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
root = r"C:\Users\av.antonov\git\tms_x5_integrationobjects"
|
||||
|
||||
for dirpath, _, files in os.walk(root):
|
||||
for fname in files:
|
||||
# 1. Удалить все .json файлы
|
||||
if fname.endswith(".json"):
|
||||
os.remove(os.path.join(dirpath, fname))
|
||||
print(f"Deleted: {fname}")
|
||||
continue
|
||||
|
||||
# 2. Сменить [Code].ext -> .bsl
|
||||
if " [Code].ext" in fname:
|
||||
new_name = fname.replace(" [Code].ext", ".bsl")
|
||||
# 3. Убрать префикс [...] в начале имени
|
||||
elif fname[0] == "[":
|
||||
new_name = re.sub(r"^\[[^\]]*\]\s*", "", fname)
|
||||
else:
|
||||
continue
|
||||
|
||||
old_path = os.path.join(dirpath, fname)
|
||||
new_path = os.path.join(dirpath, new_name)
|
||||
os.rename(old_path, new_path)
|
||||
print(f"Renamed: {fname} -> {new_name}")
|
||||
Reference in New Issue
Block a user