一、背景
https://www.52pojie.cn/forum.php ... ypeid%26typeid%3D29
二、运行界面如下,简单随便,懒得
三、教程
1、右键,以管理员身份运行;
2、依次输入3个路径,微信应用程序、微信接收文件夹以及微信整理后的文件夹,如下图,
3、输入微信程序的版本名称,如下图,
四、打包的链接
链接: https://pan.baidu.com/s/1wn6f8z4WlAHOpZw-0YswPA 提取码: n4cq
密码:52pojie
五、代码
[Python] 纯文本查看 复制代码 from pywinauto import Desktop, Application
import pyautogui
import re
import os
import shutil
data_dic={}
folder_name=[]
file_name=[]
os.environ.update({"__COMPAT_LAYER":"RUnAsInvoker"})
wx_pro_path=input('输入微信程序路径并按回车键:')
old_file_path=input('输入微信文件路径并按回车键:')
folder_path=input('创建微信整理文件,输入路径并按回车键:')
wx_title=input('输入微信版本并按回车键:')
app = Application(backend='uia').start(wx_pro_path)
win_main_Dialog = Desktop(backend='uia').window(title=wx_title)
wj=win_main_Dialog.window(title='微信文件')
wj.click_input()
win_main_Dialog = Desktop(backend='uia').window(title='微信文件')
wj2=win_main_Dialog.child_window(title='全部')
wj2.click_input()
for i in range(6):
wj2.type_keys("{TAB}")
wj2.type_keys("{ENTER}")
for i in range(3):
wj2.type_keys("{DOWN}")
wj2.type_keys("{ENTER}")
for i in range(11):
wj2.type_keys("{TAB}")
def read_data():
str_n='te'
list_now=[]
for i in range(1,8):
fi_n=win_main_Dialog.children()[1].children()[2].children()[1].children()[1].children()[0].children()[0].children()[0].children()[0].children()[i].children()[0].children()[0].children()[1].children()[0].children()[0].children()[0].children()[0].window_text()
fo_n=win_main_Dialog.children()[1].children()[2].children()[1].children()[1].children()[0].children()[0].children()[0].children()[0].children()[i].children()[0].children()[0].children()[1].children()[0].children()[1].children()[0].window_text()
date_n=win_main_Dialog.children()[1].children()[2].children()[1].children()[1].children()[0].children()[0].children()[0].children()[0].children()[i].children()[0].children()[0].children()[1].children()[1].children()[0].children()[1].window_text()
if fo_n[-3:] == '的聊天':
fo_n=re.findall('与(.*)的聊天',fo_n)[0]
else:
number=re.search(u"\|(.*?)",fo_n).span()[1]+1
fo_n=fo_n[number:]
list_now.append(fi_n.strip()[:2])
str_n+=fi_n.strip()[:2]
file_name.append(fi_n.strip())
folder_name.append(fo_n.strip())
return list_now,str_n
def press_down(down_num):
for i in range(down_num):
pyautogui.press('down')
str_b=read_data()
press_down(8)
press_down(7)
str_n=read_data()
print(11)
while str_b!=str_n:
str_b=str_n
press_down(7)
str_n=read_data()
print('data')
for i in range(len(file_name)):
if file_name[i] in data_dic:
data_dic[file_name[i]]+=[folder_name[i]]
else:
data_dic[file_name[i]]=[folder_name[i]]
for i in set(folder_name):
try:
os.makedirs(os.path.join(folder_path,i))
except OSError:
print(i)
print('folder')
for root,dirs,files in os.walk(old_file_path):
for file in files:
old_path=os.path.join(root,file)
f_name=os.path.splitext(file)[0]
f_name_s=os.path.splitext(file)[1]
while f_name[-3:]=='(1)':
f_name=f_name[0:-3]
try:
des_path_list=data_dic[f_name+f_name_s]
for j in des_path_list:
des_path=os.path.join(folder_path,j,file)
shutil.copyfile(old_path,des_path)
except KeyError:
print('wu')
print(os.path.join(root,file))
except OSError:
print('os')
print(os.path.join(root,file)) |