#-*- coding:utf-8 -*-
import shutil
import os
from Tkinter import *
import time
import re def get_all_file(adr): all_adr=[]
all_dir.append(adr)
adr+='\\'
if os.path.exists(adr):
try:
all_adr=os.listdir(adr)
except Exception,e:
print e
for i in all_adr:
#print adr+i
if os.path.isfile(adr+i):
file.append(adr+i)
dict_file[adr+i]=str(int(get_file_size(adr+i))/1024)
if os.path.isdir(adr+i):
get_all_file(adr+i) def get_file_size(adr):
if os.path.isfile(adr):
return os.path.getsize(adr) def search_file(file,key):
search_result=[]
for f in file:
for k in key:
if k in f.lower():
print f
shutil.copyfile(f,'D:\\result\\'+os.path.basename(f))
search_result.append(f) return search_result if __name__=='__main__':
dict_file={}
adr='E:\\'
all_dir=[]
file=[]
get_all_file(adr)
with open(r'C:\Users\cchen\Desktop\allfile.txt','w+') as f:
for i in file:
#print i+'\t'+dict_file[i]
f.write(i+'\t'+dict_file[i]+'\n')
'''
for j in all_dir:
print j
''' search_key=['.jpg','.png','jpeg','gif','bmp'] with open(r'C:\Users\cchen\Desktop\searchfile.txt','w+') as sf:
for i in search_file(file,search_key):
print i+'\t'+dict_file[i]
sf.write(i+'\t'+dict_file[i]+'\n')

A simple script to get all pictures的更多相关文章

  1. Upgrade NE script with GUI but cannot support multithread, need to add soon

    #-*- coding:utf-8 -*- __authour__='CC' from Tkinter import *import osimport telnetlibimport timeimpo ...

  2. [Notes] AWS Automation using script and AWS CLI

    (c) 2014 Amazon Web Services, Inc. and its afflialtes, All rights reserved. The content in this file ...

  3. Linux From Scratch(从零开始构建Linux系统,简称LFS)- Version 7.7(一)

    一. 准备工作 1. 需要一个Linux宿主系统,例如早先版本的 LFS,Ubuntu/Fedora,SuSE 或者是在你的架构上可以运行的其它发行版 如果想实现Win7与Linux双系统,可参考我的 ...

  4. How to step through your code in chrome

    By executing code one line or one function at a time, you can observe changes in the data and in the ...

  5. test for cvx library in matlab - windows

    Download the zip file of cvx http://cvxr.com/cvx/download/ by downloading cvx-w64.zip Require a lice ...

  6. (copy) Top Ten Reasons not to use the C shell

    http://www.grymoire.com/Unix/CshTop10.txt ========================================================== ...

  7. cygwin 安装apt-cyg命令

    googlecode关闭了.没法用wget安装apt-cyg 找了半天只有github里有个方法可行: apt-cyg is a simple script. To install: lynx -so ...

  8. RASPBERRY PI 外设学习资源

    参考: http://www.siongboon.com/projects/2013-07-08_raspberry_pi/index.html Raspberry Pi         Get st ...

  9. Raspberry Pi UART with PySerial

    参考:http://programmingadvent.blogspot.hk/2012/12/raspberry-pi-uart-with-pyserial.html Raspberry Pi UA ...

随机推荐

  1. delphi之TDataset

    最近遇到了很多问题,现在做一下总结. 字符串处理: 字符串相加 var S1, S2: String; begin S1 := Concat('A', 'B'); // 连接两个字符串,S1变量等于A ...

  2. sql之连表查询--效率 通过分析各种连接查询的实现原理来了解

    1. 左连接 2.右连接 3.内连接 4.Cross join 笛卡尔乘积

  3. 3个著名加密算法(MD5、RSA、DES)的解析

    MD5的全称是Message-Digest Algorithm 5,在90年代初由MIT的计算机科学实验室和RSA Data Security Inc发明,经MD2.MD3和MD4发展而来.    M ...

  4. [总结] JDBC数据库操作

    1.加载驱动--告诉驱动管理将使用哪一个数据库的驱动包. class.forName("com.mysql.jdbc.Driver"); 2.操作JDBC ADI完成数据库动作 D ...

  5. LA 3942 - Remember the Word (字典树 + dp)

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  6. Android 多媒体视频播放一( 多媒体理解与经验分享)

    前言 说到android的多媒体,一把辛酸一把泪,当初听说会多媒体的比较牛掰,公司也有需求,于是乎我也积极的加入研究android多媒体的行列,记得以前刚接触的时候,最开始还是比较头大的,主要是但是很 ...

  7. xml 的读写

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. Application Engine

    Exit(1) : Terminate the AE immediately and rollback all DB changes madeexit(0) : Terminate the AE im ...

  9. 最好的cpm广告联盟哪里有

    最好的cpm广告联盟哪里有,58传媒广告联盟还要提醒众位站长的是网站在经营发展中必须最大化的扩展自己的优势力量.每个网站都有属于自己的优势魅力,这些优势特点只有得到最大化的发挥才能为网站带来意想不到的 ...

  10. 二十五、JDK1.5新特性---枚举

    与上篇文章介绍的相同,本文也是介绍jdk 1.5出现的新特性,本文将介绍枚举的相关用法. 在jdk 1.5 之前.Java可以有两种方式定义新类型:类和接口.对于大部分面向对象来说.这两种方法看起来似 ...