forked from eunomia-bpf/bpf-developer-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrename.py
More file actions
34 lines (27 loc) · 1.26 KB
/
Copy pathrename.py
File metadata and controls
34 lines (27 loc) · 1.26 KB
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
31
32
33
34
import os
def rename_readme_en_to_readme(base_dir):
# First pass: Rename README_en.md to README.md
for root, dirs, files in os.walk(base_dir):
for file in files:
file_path = os.path.join(root, file)
# Rename README_en.md to README.md
if file == "README_en.md":
new_file_path = os.path.join(root, "README.md")
os.rename(file_path, new_file_path)
print(f"Renamed {file_path} to {new_file_path}")
def rename_readme_to_readme_zh(base_dir):
# Second pass: Rename README.md to README.zh.md
for root, dirs, files in os.walk(base_dir):
for file in files:
file_path = os.path.join(root, file)
# Rename README.md to README.zh.md if it exists
if file == "README.md":
zh_file_path = os.path.join(root, "README.zh.md")
os.rename(file_path, zh_file_path)
print(f"Renamed {file_path} to {zh_file_path}")
# Example usage
base_directory = "/root/bpf-developer-tutorial/src" # Replace with the actual base directory
# Second pass: Rename README.md to README.zh.md
rename_readme_to_readme_zh(base_directory)
# First pass: Rename README_en.md to README.md
rename_readme_en_to_readme(base_directory)