diff --git a/python/changeFileName.py b/python/change_filename.py similarity index 97% rename from python/changeFileName.py rename to python/change_filename.py index 6650396..25682cf 100644 --- a/python/changeFileName.py +++ b/python/change_filename.py @@ -1,51 +1,51 @@ -# -*- coding=utf-8 -*- -# @Time : 2023/1/14 13:22 -# @Author : LXW -# @File : changeFileName.py - -import os -import re -import sys - - -def change_file_suffix(input_file_path): - for parent_path, dir_path, filenames in os.walk(input_file_path): - for filename in filenames: - base_name = os.path.basename(parent_path) - result = re.search(base_name, filename) - if None is not result and not str(filename).endswith(".vsmeta"): - print(filename) - new_filename = filename.split(base_name + ".")[1] - os.rename(os.path.join(parent_path, filename), os.path.join(parent_path, new_filename)) - - -def delete_files(input_file_path): - for parent_path, dir_path, filenames in os.walk(input_file_path): - for filename in filenames: - if str(filename).endswith(".vsmeta"): - os.remove(os.path.join(parent_path, filename)) - - -def change_naruto(input_file_path): - for parent_path, dir_path, filenames in os.walk(input_file_path): - for filename in filenames: - base_name = os.path.basename(parent_path) - result = re.search(base_name, filename) - if None is not result and not str(filename).endswith(".vsmeta") and not str(filename).endswith(".srt") and not str(filename).endswith(".ass"): - print(filename) - first_split = filename.split("[西行纪][The Westward][") - if len(first_split) > 1: - # number = first_split[1].split(".")[0].replace(" ", "") - # new_filename = base_name+"."+number+".mp4" - - number = first_split[1] - new_number = number.split("]")[0] - new_filename = "西行纪.The Westward.S01E" + new_number + ".mp4" - os.rename(os.path.join(parent_path, filename), os.path.join(parent_path, new_filename)) - - -if __name__ == '__main__': - # __input_file_path = sys.argv[1] - __input_file_path = "F:\download\西行纪" - change_naruto(input_file_path=__input_file_path) - delete_files(input_file_path=__input_file_path) +# -*- coding=utf-8 -*- +# @Time : 2023/1/14 13:22 +# @Author : LXW +# @File : changeFileName.py + +import os +import re +import sys + + +def change_file_suffix(input_file_path): + for parent_path, dir_path, filenames in os.walk(input_file_path): + for filename in filenames: + base_name = os.path.basename(parent_path) + result = re.search(base_name, filename) + if None is not result and not str(filename).endswith(".vsmeta"): + print(filename) + new_filename = filename.split(base_name + ".")[1] + os.rename(os.path.join(parent_path, filename), os.path.join(parent_path, new_filename)) + + +def delete_files(input_file_path): + for parent_path, dir_path, filenames in os.walk(input_file_path): + for filename in filenames: + if str(filename).endswith(".vsmeta"): + os.remove(os.path.join(parent_path, filename)) + + +def change_naruto(input_file_path): + for parent_path, dir_path, filenames in os.walk(input_file_path): + for filename in filenames: + base_name = os.path.basename(parent_path) + result = re.search(base_name, filename) + if None is not result and not str(filename).endswith(".vsmeta") and not str(filename).endswith(".srt") and not str(filename).endswith(".ass"): + print(filename) + first_split = filename.split("[西行纪][The Westward][") + if len(first_split) > 1: + # number = first_split[1].split(".")[0].replace(" ", "") + # new_filename = base_name+"."+number+".mp4" + + number = first_split[1] + new_number = number.split("]")[0] + new_filename = "西行纪.The Westward.S01E" + new_number + ".mp4" + os.rename(os.path.join(parent_path, filename), os.path.join(parent_path, new_filename)) + + +if __name__ == '__main__': + # __input_file_path = sys.argv[1] + __input_file_path = "F:\download\西行纪" + change_naruto(input_file_path=__input_file_path) + delete_files(input_file_path=__input_file_path)