diff --git a/rename.py b/rename.py new file mode 100644 index 0000000..89177a2 --- /dev/null +++ b/rename.py @@ -0,0 +1,155 @@ +import os + +path = r'D:\bishe\data_set\sn_data\sn\baibu' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\baishao' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\gouqi' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\huangjing' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\jianghuang' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\lulutong' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\puhuang' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\shechuangzi' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\yimucao' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\yujin' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 + +path = r'D:\bishe\data_set\sn_data\sn\zhiqiaopian' +filelist = os.listdir(path) +# 开始文件名1000.jpg +count = 10000 +for file in filelist: + Olddir = os.path.join(path, file) + if os.path.isdir(Olddir): + continue + filename = os.path.splitext(file)[0] + filetype = os.path.splitext(file)[1] + Newdir = os.path.join(path, str(count) + filetype) + os.rename(Olddir, Newdir) + count += 1 \ No newline at end of file