|
|
本帖最后由 liyuanhe211 于 2017-2-8 14:49 编辑
将你一楼的脚本保存为 std.lsf,把下列文件保存为 x.py,都放在装有你要批量运行文件的文件夹下
则运行 python x.py 会自动提交当前文件夹下的所有.gjf文件
- # -*- coding: utf-8 -*-
- import sys
- import os
- import subprocess
- path = os.path.split(os.path.abspath(sys.argv[0]))[0] #Bug fixed by ggdh at 9L
- if not os.path.isfile(os.path.join(path,'std.lsf')):
- print("A standard LSF file [std.lsf] must be provided, leaving INPUT=xxx.gjf")
- exit()
- with open(os.path.join(path,'std.lsf')) as std_lsf_file:
- std_lsf = std_lsf_file.read()
- files = os.listdir(path)
- files = [x.split('.')[0] for x in files if x.split('.')[-1]=='gjf']
- print(files)
- for file in files:
- with open(file+".lsf",'w') as output_lsf_file:
- output_lsf_file.write(std_lsf.replace('xxx',file))
- subprocess.Popen(['chmod','777',file+".lsf"])
- subprocess.Popen(['dos2unix',file+".lsf"])
- subprocess.Popen(['bsub',file+".lsf"])
复制代码
|
评分 Rate
-
查看全部评分 View all ratings
|