转移大于2m的pdf文件到另外一个文件夹

https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

转移大于2m的pdf文件到另外一个文件夹

转移大于2m的pdf文件到另外一个文件夹

remove_moret2M_pdfs.py

# -*- coding: utf-8 -*-
"""
Created on Mon Sep 19 09:36:48 2016 @author: Administrator
""" import os
from os.path import join, getsize import shutil,xlrd excelFilename="test.xlsx"
sheetName="Sheet1"
data = xlrd.open_workbook(excelFilename)
table = data.sheets()[0]
#总pdf列表
totalpdfs_list=table.col_values(0)
pdf_test="20160607_2.pdf"
#存储大于2M的pdf文件
list_bigFileSize=[] #存储大于2M的pdf文件列表
def get_list_bigFileSize(): for file in totalpdfs_list:
size= getsize(file)
if size>2048000:
list_bigFileSize.append(file)
return list_bigFileSize #移动函数,目录里不匹配文件移入unmatching_file文件夹
def RemoveFile():
dir="大于2M的pdf"
for file in list_bigFileSize:
shutil.move(file,dir) list_bigFileSize=get_list_bigFileSize()
RemoveFile()
上一篇:还能输入多少字?(JS动态计算)


下一篇:android开发学习笔记系列(3)--ScrollView与HorizontalScrollView