GithubHelp home page GithubHelp logo

xiangmiao / finddocs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aibow/finddocs

0.0 1.0 0.0 25 KB

搜索指定目录中包含指定关键词的word文档

License: Apache License 2.0

Python 100.00%

finddocs's Introduction

搜索指定目录中包含指定关键词的word文档

由于采用win32com,所以仅支持windows系统
windows系统必须安装office word软件
需要python 2.7.x环境支持
需要pywin32库支持

参数说明

python main.py -h
  • -h: 帮助信息
  • -d: 指定要搜索的目录,支持递归检索,请使用绝对路径
  • -w: 指定要搜索的关键词文件,每行一个关键词,#表示注释,区分大小写
  • -f: 是否清理上次执行遗留的缓存.如果取值为0,那么搜索出错中断,可以继续接上次进度执行.如果取值为1,那么将会清理上次执行的数据.

演示

命令

python main.py -d d:/FindDocs/test -w words.txt -f

输出内容

[2016-05-25 11:29:48] Application Starting ...
[2016-05-25 11:29:48] Loading Word File ...
[2016-05-25 11:29:48] Word File Load Success, Find 4 Word
[2016-05-25 11:29:48] Find Doc File ...
[2016-05-25 11:29:48] Find Success, Find 8 Document
[2016-05-25 11:29:48] Preprocessor Document ...
[2016-05-25 11:29:48] Convert Document D:\FindDocs\test\folder\folder\empty.docx
[2016-05-25 11:29:48] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:29:48] Convert Document D:\FindDocs\test\folder\folder\文档 - 副本.doc
[2016-05-25 11:29:51] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:29:51] Convert Document D:\FindDocs\test\folder\folder\文档 - 副本.docx
[2016-05-25 11:29:54] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:29:54] Convert Document D:\FindDocs\test\folder\folder\文档.docx
[2016-05-25 11:29:56] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:29:56] Convert Document D:\FindDocs\test\empty.docx
[2016-05-25 11:29:58] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:29:58] Convert Document D:\FindDocs\test\文档 - 副本.doc
[2016-05-25 11:30:02] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:30:02] Convert Document D:\FindDocs\test\文档 - 副本.docx
[2016-05-25 11:30:06] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:30:06] Convert Document D:\FindDocs\test\文档.docx
[2016-05-25 11:30:09] Convert Document {D:\FindDocs\doc.tmp} Success
[2016-05-25 11:30:09] Preprocessor Document Success
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\folder\folder\empty.docx} ...
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\folder\folder\文档 - 副本.doc} ...
[2016-05-25 11:30:09] D:\FindDocs\test\folder\folder\文档 - 副本.doc:2:关键词,$#%
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\folder\folder\文档 - 副本.docx} ...
[2016-05-25 11:30:09] D:\FindDocs\test\folder\folder\文档 - 副本.docx:2:关键词,$#%
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\文档 - 副本.doc} ...
[2016-05-25 11:30:09] D:\FindDocs\test\文档 - 副本.doc:2:关键词,$#%
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\folder\folder\文档.docx} ...
[2016-05-25 11:30:09] D:\FindDocs\test\folder\folder\文档.docx:2:关键词,$#%
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\文档.docx} ...
[2016-05-25 11:30:09] D:\FindDocs\test\文档.docx:2:关键词,$#%
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\文档 - 副本.docx} ...
[2016-05-25 11:30:09] D:\FindDocs\test\文档 - 副本.docx:2:关键词,$#%
[2016-05-25 11:30:09] Check Document {D:\FindDocs\test\empty.docx} ...
[2016-05-25 11:30:09] Application Finished

结果记录文件result.txt内容

D:\FindDocs\test\folder\folder\文档 - 副本.doc:2:关键词,$#%
D:\test\folder\folder\文档 - 副本.docx:2:关键词,$#%
D:\FindDocs\test\文档 - 副本.doc:2:关键词,$#%
D:\FindDocs\test\folder\folder\文档.docx:2:关键词,$#%
D:\FindDocs\test\文档.docx:2:关键词,$#%
D:\FindDocs\test\文档 - 副本.docx:2:关键词,$#%

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.