import os
# 输入文件夹地址
path = "/home/zhengsc/Desktop/3DUNet-Pytorch/dataset/label"
files = os.listdir(path)
# 输出所有文件名,只是为了看一下
for file in files:
print(file)
# 获取旧名和新名
i = 0
for file in files:
# old 旧名称的信息
old = path + os.sep + files[i]
# new是新名称的信息,这里的操作是删除了的'_mask'
new = path + os.sep + file.replace('volume-','segmentation-')
# 新旧替换
os.rename(old,new)
i+=1
zuihaoyongde rename
最新推荐文章于 2021-09-15 13:36:37 发布