#-*- 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. Eclipse中配置svn

    1.打开eclipse,help--> Eclipse MarketPlace...,搜索输入“subclipse”,点击安装,一路按向导安装: 2.安装成功后,在Window --> S ...

  2. PhpStorm 4.0 & 5.0 部署本地Web应用 (转)

    1.创建新的项目(project),创建完成之后单击工具栏的应用运行/调试(Select Run/Debug Configuration)的下拉菜单弹出 Edit Cofigurations选项,单击 ...

  3. c 头文件<ctype.h>(二)

    测试<ctype.h>函数 #include <stdio.h> #include <ctype.h> int main(){ ; ; i < ; ++i){ ...

  4. LeetCode:Two Sum II

    public class Solution { public int[] twoSum(int[] numbers, int target) { int left = 0; int right = n ...

  5. 总结Android中遇见的OOM

    一 .Android应用中内存泄漏几种的原因: 1.单例模式导致的内存泄漏: 当调用getInstance时,如果传入的context是Activity的context.只要这个单例没有被释放,这个A ...

  6. JVM内存结构---《深入理解Java虚拟机》学习总结

    Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同的数据区域.这些区域的用途各不相同,同时也依据着各自的执行规则,独立的创建和销毁数据. 虚拟机内存的划分,如图所示: 线程之间 ...

  7. Java 之 List<T> 接口的实现:ArrayList

    Collection├List│├LinkedList│├ArrayList│└Vector│ └Stack└SetMap├Hashtable├HashMap└WeakHashMap ArrayLis ...

  8. vue-cli安装失败问题

    1.尝试 管理员权限 安装,看是否能解决问题 2.仍未解决问题, 系统变量增加:  C:\Program Files\nodejs\node cache\node_modules\vue-cli\bi ...

  9. c#中按键小技巧

    以后会补充其他的内容

  10. SWFUpload

    引用:http://www.cnblogs.com/2050/archive/2012/08/29/2662932.html SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非 ...