python实现办公自动化

python实现办公自动化

import os, sys
from os import walk, mkdir, rename, path
from shutil import copy, move
import time
from openpyxl import load_workbook

#批量重命名文件
path = ‘venv\html’
for root, folders, files in walk(path):

counter = 0
for name in files:
    print(root)
    type_name = root.split('\\')[-1]
    print(type_name)
    renamed = type_name+str(counter)+'python.html'
    print(os.path.join(root, name))
    #注意这里为全路径  源文件   目标文件
    rename(os.path.join(root, name), os.path.join(root, renamed))
    counter += 1

你可能感兴趣的:(scratch,python,python)