批量生成ETL Automation APP下Perl脚本执行目录,etlperl,批量生成ETL Auto


批量生成ETL Automation调用Perl脚本时所需的目录结构与控制文件

import osimport sysimport shutilimport time# Perl脚本所在目录,由shell参数的形式传入path = sys.argv[1]# 控制文件名control = "control.pl"# 遍历path目录下的所有文件并创建与文件名对应的目录def ls(path):    dirs = os.listdir(path)    for title in dirs:        if (os.path.isdir(os.path.join(path,title))) or (title.find(control) != -1):            continue        else:            dirname = title[:-7].upper()            binname = dirname + os.sep + "bin"            controlfile = binname + os.sep + title[:-7] + "_0400.pl"            os.mkdir(os.path.join(path,dirname))            os.mkdir(os.path.join(path,binname))             shutil.copy2(os.path.join(path,title),os.path.join(path,binname))             shutil.copy2(os.path.join(path,control),os.path.join(path,controlfile))# 批量删除path下的文件,并备份到指定目录def remove(path):    dirs = os.listdir(path)    today = path + os.sep + time.strftime("%Y%m%d")    if not os.path.exists(today):        os.mkdir(today)    for title in dirs:        abspath = os.path.join(path,title)        if os.path.isdir(abspath):            continue        else:            shutil.copy2(abspath,os.path.join(path,today))            os.remove(abspath)ls(path)remove(path)#该片段来自于http://byrx.net

评论关闭