微信接收文件自动分类整理(已打包exe)
一、背景https://www.52pojie.cn/forum.php?mod=viewthread&tid=1468002&extra=page%3D2%26filter%3Dtypeid%26typeid%3D29
二、运行界面如下,简单随便,懒得
三、教程
1、右键,以管理员身份运行;
2、依次输入3个路径,微信应用程序、微信接收文件夹以及微信整理后的文件夹,如下图,
3、输入微信程序的版本名称,如下图,
四、打包的链接
链接: https://pan.baidu.com/s/1wn6f8z4WlAHOpZw-0YswPA 提取码: n4cq
密码:52pojie
五、代码
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().children().children().children().children().children().children().children().children().children().children().children().children().children().children().children().window_text()
fo_n=win_main_Dialog.children().children().children().children().children().children().children().children().children().children().children().children().children().children().children().window_text()
date_n=win_main_Dialog.children().children().children().children().children().children().children().children().children().children().children().children().children().children().children().window_text()
if fo_n[-3:] == '的聊天':
fo_n=re.findall('与(.*)的聊天',fo_n)
else:
number=re.search(u"\|(.*?)",fo_n).span()+1
fo_n=fo_n
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 in data_dic:
data_dic]+=]
else:
data_dic]=]
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)
f_name_s=os.path.splitext(file)
while f_name[-3:]=='(1)':
f_name=f_name
try:
des_path_list=data_dic
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)) 太高级了 {:1_921:} pywinauto.findwindows.ElementNotFoundError: {'title': '微信 3.3.0.93', 'top_level_only': True, 'backend': 'uia'} 感谢分享,去试试 正好需要 微信版本号 3.3.0.93按步骤运行完后闪退 3.3.0.93 微信版本报错,瞬间消失。 很实用,。谢谢 有点儿意思 不错 感谢楼主 感谢分享