- 论坛徽章:
- 4
|
本帖最后由 mswsg 于 2016-05-03 22:24 编辑
当前大文件夹?就是当前文件夹?找到settings文件所在的目录,并在此目录下运行命令 openmc | tee out.txt , 产生out.txt(与settings在同一目录)
python search.py your_path settings- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import os
- import sys
- __author__ = 'shengwei ma'
- __author_email__ = 'shengweima@icloud.com'
- def search(path, word):
- for filename in os.listdir(path):
- fp = os.path.join(path, filename)
- if os.path.isfile(fp) and word in filename:
- print fp
- dir_n, fi = os.path.split(fp)
- os.system('cd %s | openmc | tee out.txt' % dir_n)
- elif os.path.isdir(fp):
- search(fp, word)
- search(sys.argv[1], sys.argv[2])
复制代码 |
|