forked from liteli1987gmail/full_course_langchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddPadding.py
30 lines (23 loc) · 897 Bytes
/
addPadding.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import subprocess
# 指定 cn_docs 文件夹的路径
folder_path = './pages/'
def batchAdd(folder_path=folder_path):
for root, dirs, files in os.walk(folder_path):
for file_name in files:
# 构建文件的完整路径
file_path = os.path.join(root, file_name)
# new_file_path = file_path.replace(' ', '') # 删除空字符串
# # 更新文件系统中的文件名
# os.rename(file_path, new_file_path)
# 构建要执行的命令
command = f'npx md-padding -i {file_path}'
# 执行命令
subprocess.run(command, shell=True)
if not folder_path.endswith('md'):
# print(folder_path)
batchAdd(folder_path)
else:
file_path = folder_path
command = f'npx md-padding -i {file_path}'
subprocess.run(command, shell=True)