import os,sys
import os.path
rootdir=sys.path[0]
#需要过滤的文件
notActionFile = ["choose_bg1.png"]
#需要过滤的文件夹
notActionPath = ["test"]
#需要删除的文件
needDeleteFile = ["s2.png"]
def file_extension(path):
return os.path.splitext(path)[1]
for parent,dirnames,filenames in os.walk(rootdir):
for filename in filenames:
fullPath = os.path.join(parent,filename)
#删除文件
for deleteFile in needDeleteFile:
if filename == deleteFile:
os.remove(fullPath)
isFilter = False
#过滤文件压缩
for noActionName in notActionFile:
if noActionName == filename:
isFilter = True
#过滤文件夹压缩
for onePath in notActionPath:
lastPath = fullPath.split('\\')[-2]
if lastPath == onePath:
isFilter = True
if file_extension(fullPath) == ".png" and isFilter == False:
#print "action"
os.system("pngquant -f --ext .png --quality 50-80 \"" + fullPath + "\"")
print fullPath
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有