转移大于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()