|
发表于 2020-4-21 19:20:24
|
显示全部楼层
bat不会 python会一点 不知道能不能行
[ol]import osimport shutilimport timeimport logginglogging.basicConfig(level=logging.DEBUG)path = "./testDir"newPath = "./newDir"year = 2020month = 4day = 1if(not os.path.isdir(newPath)): os.mkdir(newPath)dt = '{}-{}-{}'.format(year,month,day)ts = int(time.mktime(time.strptime(dt, "%Y-%m-%d")))for i in os.listdir(path): fileName = path + "/" + i newFileName = newPath + "/" + i changeTime = os.stat(fileName) ct = changeTime.st_mtime if(ct>=ts): try: shutil.copy(fileName, newFileName) logging.info("copy {} to {} successfully!".format(fileName,newFileName)) except Exception as e: logging.error("copy {} to {} unsuccessfully!=>{}".format(fileName, newFileName,e))[/ol]复制代码 |
|