# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import os
def rename_gopro_all():
# Use a breakpoint in the code line below to debug your script.
path = "./"
count = 0
file_list = os.listdir(path)
print (file_list)
for file in file_list:
if 'GH' in file:
olddir = os.path.join(path,file)
if os.path.isdir(olddir):
continue
filename = os.path.splitext(file)[0]
filetype = os.path.splitext(file)[1].upper()
if filetype in [".MP4",".JPG",".LRV",".THM"] and filename[0]=="G" and "_" not in filename:
NAME_PREFIX = filename[:2]
NAME_INDEX = filename[2:4]
NAME_SEQ = filename[4:]
newdir = os.path.join(path, NAME_PREFIX + NAME_SEQ + "_" + NAME_INDEX + filetype.lower())
print (newdir)
os.rename(olddir,newdir)
count +=1
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
rename_gopro_all ()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
感谢代码的贡献者GOPRO的命名规则及改名脚本【gopro吧】_百度贴吧