用Python批量修改文件名

import os
dir = os.getcwd()
subdir = os.listdir(dir)
for i in subdir:
    path = os.path.join(dir, i)
    if os.path.isdir(path):
        end_dir = os.listdir(path)
        for i in range(len(end_dir)):
            newname = end_dir[i][0:50]
            os.rename(os.path.join(path, end_dir[
                      i]), os.path.join(path, newname))


#小编准备了一份Python的最新系统资料,548-377-875 都在这个群里了~

猜你喜欢

转载自blog.csdn.net/python_huohuo/article/details/82986075