资源简介
自己用python写的桌面清理小工具,配置文件填写保留文件,目录执行脚本,桌面瞬间变干净,相关清理文件会备份到配置目录

代码片段和文件信息
import os
import datetime
import shutil
import ConfigParser
def title():
print ‘###############Start cleaning desktop###############‘
def end():
print ‘###############Desktop clean end###############‘
def readConfig():
global curDir backupdir desktopbak cnfFile path dirItems fileItems bakItems
curDir = os.getcwd()
cnfFile = curDir + os.sep + “desktop.cnf“
cnf = ConfigParser.ConfigParser()
cnf.read(cnfFile)
path = cnf.get(‘Monitor‘ ‘pathItems‘)
bakItems = cnf.get(‘Monitor‘ ‘bakItems‘)
backupdir=datetime.datetime.now().strftime(“%Y%m%d%H%M%S“)
desktopbak=bakItems+backupdir
dirItems = cnf.get(‘Monitor‘ ‘dirItems‘)
fileItems = cnf.get(‘Monitor‘ ‘fileItems‘)
def listDir(fileDir):
for eachFile in os.listdir(fileDir):
if os.path.isdir(fileDir+“/“+eachFile):
if eachFile not in dirItems:
df=fileDir+“/“+eachFile
print ‘Backup Directory‘+“ “+df
shutil.move(dfdesktopbak)
if os.path.isfile(fileDir+“/“+eachFile):
if eachFile not in fileItems:
ef=fileDir+“/“+eachFile
print ‘Backup File‘+“ “+ef
shutil.move(efdesktopbak)
def createdir():
if os.path.exists(desktopbak):
print ‘Backup directory already exists‘
else:
os.makedirs(desktopbak)
if __name__==‘__main__‘:
title()
readConfig()
createdir()
listDir(path)
end()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 201 2018-05-13 11:56 desktopclean\desktop.cnf
文件 1616 2018-05-13 11:19 desktopclean\desktopclear.py
目录 0 2018-05-13 11:55 desktopclean
----------- --------- ---------- ----- ----
1817 3
相关资源
- Python-BDD100K大规模多样化驾驶视频数据
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
评论
共有 条评论