-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathfix_folder.py
More file actions
26 lines (20 loc) · 1.08 KB
/
fix_folder.py
File metadata and controls
26 lines (20 loc) · 1.08 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
import re
with open('wechat_cli/commands/export_all_accounts.py', 'r', encoding='utf-8') as f:
content = f.read()
# 找到并替换
old_text = ''' # 创建聊天目录
safe_name = chat_name.replace('/', '_').replace('\\', '_').replace(':', '_')
chat_dir = account_dir / safe_name
chat_dir.mkdir(parents=True, exist_ok=True)'''
new_text = ''' # 创建聊天目录
folder_name = chat_info['display_name'] or chat_info['username']
# 如果 display_name 是表名(Msg_xxx),用 username
if folder_name.startswith('Msg_'):
folder_name = chat_info['username'] if not chat_info['username'].startswith('Msg_') else folder_name
safe_name = folder_name.replace('/', '_').replace('\\', '_').replace(':', '_')
chat_dir = account_dir / safe_name
chat_dir.mkdir(parents=True, exist_ok=True)'''
content = content.replace(old_text, new_text)
with open('wechat_cli/commands/export_all_accounts.py', 'w', encoding='utf-8') as f:
f.write(content)
print("已修复")