import os
from pathlib import Path
import tkinter as tk
import screen_brightness_control as sbc
FILE_FORMAT={"图片":[".jpg",".jpeg",".bpm",'.png','.gif'],
"文档":[".doc",".docx",".xls",".xlsx",".ppt",".wps",".pptx",".pdf",".txt",".md",".pub"],
"视频":[".mp4","avi","wmv",],
"音频":[".mp3"],
"压缩":[".rar",".zip",".tar",".gz",".7z","bz"],
"脚本":[".ps1",".sh",".bat",".py"],
"可执行文件":['.exe','.msi'],
"网页文件":['.html','.xml','.mhtml','.html'],
"快捷方式":[".lnk"]
}
def get_user_input():
user_input = entry.get()
print(user_input)
orginizePath = user_input # 目标路径
try:
print(os.scandir(orginizePath))
for myfile in os.scandir(orginizePath):
# 定义要整理的文件夹orgPath='D:\\direct'print(os.scandir(orgPath))#循环整理的文件夹。for myfile in os.scandir(orgPath): #跳过file
# 桌面C:/Users/tfpc/Desktop
file_path = Path(orginizePath + '/' + myfile.name)
directory_path1 = Path(orginizePath + '/目录')
if myfile.is_dir():
print('%s是文件夹' % myfile.name)
directory_path1.mkdir(exist_ok=True)
file_path.rename(directory_path1.joinpath(myfile.name))
continue
# 输出文件
print(myfile.name)
# 找到要整理的文件路径
# file_path=Path(orginizePath+'/'+myfile.name)
lower_file_path = file_path.suffix.lower() # 循环遍历我们定义的格式类型
for formt in FILE_FORMAT:
if lower_file_path in FILE_FORMAT[formt]:
directory_path = Path(orginizePath + '/' + formt)
directory_path.mkdir(exist_ok=True)
file_path.rename(directory_path.joinpath(myfile.name))
print('文件整理已完成!')
result_label.config(text="文件整理已完成!")
except Exception as err:
result_label.config(text="请输入正确的文件路径!")
# 创建Tkinter窗口
root = tk.Tk()
root.title("请输入要整理的文件路径")
sw = root.winfo_screenwidth()
#得到屏幕宽度
sh = root.winfo_screenheight()
#得到屏幕高度
ww = 400
wh = 150
#窗口宽高为100
x = (sw-ww) / 2
y = (sh-wh) / 2
root.geometry("%dx%d+%d+%d" %(ww,wh,x,y))
#root.geometry('400x100')
# 创建文本框
entry = tk.Entry(root)
entry.pack()
# 创建一个按钮,用于触发获取用户输入的操作
get_input_button = tk.Button(root, text="确定", command=get_user_input)
get_input_button.pack()
# 创建一个标签,用于显示用户输入的结果
result_label = tk.Label(root, text="")
result_label.pack()
#护眼模式
l=tk.Label(root, width=20, text='护眼模式')
l.pack()
primary_brightness = sbc.get_brightness(display=0)
primary_brightness = list(primary_brightness)[0]
print(primary_brightness)
def print_selection():
if (var1.get() == 1):
sbc.set_brightness(40)
print(sbc.get_brightness())
l.config(text='护眼模式已打开')
else:
sbc.set_brightness(primary_brightness)
print(sbc.get_brightness())
l.config(text='护眼模式已关闭')
var1 = tk.IntVar()
c1=tk.Checkbutton(root,text='护眼模式',variable=var1,onvalue=1,offvalue=0,command=print_selection)
c1.pack()
# 启动Tkinter主事件循环
root.mainloop()

代码小轩
- 粉丝: 74
最新资源
- VB的图书管理系统设计与实现.doc
- 网络受众的定量研究.docx
- 大数据时代新闻资料工作的转型.docx
- 现代通信技术实验指导说明书实验.doc
- 一主线五程式在数控专业信息化教学中的运用.docx
- JAVA图书管理与实现.doc
- 中外云计算产业发展形势与比较.docx
- 《电子商务概论》项目管理任务.doc
- 通信学院本科培养实施方案.doc
- 大数据背景下的财务外包企业发展趋势.docx
- 软件项目研发管理流程.docx
- 留学大数据:《中国留学发展报告》.docx
- PLC控制四层电梯大学本科方案设计书.doc
- 基于Nodejs的SQLite多表数据自动合并工具-实现PDF文件采集过程中生成的数百至数千个结构相同数据表的高效整合-通过自动化脚本替代繁琐的手工INSERT操作-显著提升数据.zip
- ATC单片机音乐喷泉控制系统设计.doc
- 基于误差反向传播算法的代建制项目管理风险评价研究.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


