mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 23:30:44 +08:00
修复通过任务对本地(网盘)文件进行重命名时没有应用过滤规则的问题
在 do_rename_task() 函数中为所有命名模式(顺序命名、剧集命名、正则命名)添加了过滤规则检查,确保本地文件重命名时也会应用 filterwords 过滤规则
This commit is contained in:
parent
49d3994372
commit
3249c18d17
@ -3003,7 +3003,37 @@ class Quark:
|
||||
non_dir_files = [f for f in dir_file_list if not f.get("dir", False)]
|
||||
is_empty_dir = len(non_dir_files) == 0
|
||||
|
||||
|
||||
# 应用过滤词过滤(修复bug:为本地文件重命名添加过滤规则)
|
||||
if task.get("filterwords"):
|
||||
# 记录过滤前的文件总数
|
||||
original_total_count = len(dir_file_list)
|
||||
|
||||
# 同时支持中英文逗号分隔
|
||||
filterwords = task["filterwords"].replace(",", ",")
|
||||
filterwords_list = [word.strip().lower() for word in filterwords.split(',')]
|
||||
|
||||
# 过滤掉包含过滤词的文件
|
||||
filtered_files = []
|
||||
for file in dir_file_list:
|
||||
if file.get("dir", False):
|
||||
# 文件夹也需要检查过滤词
|
||||
file_name = file['file_name'].lower()
|
||||
file_ext = os.path.splitext(file_name)[1].lower().lstrip('.')
|
||||
|
||||
# 检查过滤词是否存在于文件名中,或者过滤词等于扩展名
|
||||
if not any(word in file_name for word in filterwords_list) and not any(word == file_ext for word in filterwords_list):
|
||||
filtered_files.append(file)
|
||||
else:
|
||||
# 文件检查过滤词
|
||||
file_name = file['file_name'].lower()
|
||||
file_ext = os.path.splitext(file_name)[1].lower().lstrip('.')
|
||||
|
||||
# 检查过滤词是否存在于文件名中,或者过滤词等于扩展名
|
||||
if not any(word in file_name for word in filterwords_list) and not any(word == file_ext for word in filterwords_list):
|
||||
filtered_files.append(file)
|
||||
|
||||
dir_file_list = filtered_files
|
||||
dir_file_name_list = [item["file_name"] for item in dir_file_list]
|
||||
|
||||
# 找出当前最大序号
|
||||
max_sequence = 0
|
||||
@ -3609,6 +3639,37 @@ class Quark:
|
||||
is_rename_count = 0
|
||||
renamed_files = {}
|
||||
|
||||
# 应用过滤词过滤(修复bug:为本地文件重命名添加过滤规则)
|
||||
if task.get("filterwords"):
|
||||
# 记录过滤前的文件总数
|
||||
original_total_count = len(dir_file_list)
|
||||
|
||||
# 同时支持中英文逗号分隔
|
||||
filterwords = task["filterwords"].replace(",", ",")
|
||||
filterwords_list = [word.strip().lower() for word in filterwords.split(',')]
|
||||
|
||||
# 过滤掉包含过滤词的文件
|
||||
filtered_files = []
|
||||
for file in dir_file_list:
|
||||
if file.get("dir", False):
|
||||
# 文件夹也需要检查过滤词
|
||||
file_name = file['file_name'].lower()
|
||||
file_ext = os.path.splitext(file_name)[1].lower().lstrip('.')
|
||||
|
||||
# 检查过滤词是否存在于文件名中,或者过滤词等于扩展名
|
||||
if not any(word in file_name for word in filterwords_list) and not any(word == file_ext for word in filterwords_list):
|
||||
filtered_files.append(file)
|
||||
else:
|
||||
# 文件检查过滤词
|
||||
file_name = file['file_name'].lower()
|
||||
file_ext = os.path.splitext(file_name)[1].lower().lstrip('.')
|
||||
|
||||
# 检查过滤词是否存在于文件名中,或者过滤词等于扩展名
|
||||
if not any(word in file_name for word in filterwords_list) and not any(word == file_ext for word in filterwords_list):
|
||||
filtered_files.append(file)
|
||||
|
||||
dir_file_list = filtered_files
|
||||
|
||||
# 使用一个列表收集所有需要重命名的操作
|
||||
rename_operations = []
|
||||
rename_logs = [] # 收集重命名日志
|
||||
@ -3754,6 +3815,37 @@ class Quark:
|
||||
# 获取目录中的文件列表
|
||||
dir_file_list = self.ls_dir(self.savepath_fid[savepath])
|
||||
|
||||
# 应用过滤词过滤(修复bug:为本地文件重命名添加过滤规则)
|
||||
if task.get("filterwords"):
|
||||
# 记录过滤前的文件总数
|
||||
original_total_count = len(dir_file_list)
|
||||
|
||||
# 同时支持中英文逗号分隔
|
||||
filterwords = task["filterwords"].replace(",", ",")
|
||||
filterwords_list = [word.strip().lower() for word in filterwords.split(',')]
|
||||
|
||||
# 过滤掉包含过滤词的文件
|
||||
filtered_files = []
|
||||
for file in dir_file_list:
|
||||
if file.get("dir", False):
|
||||
# 文件夹也需要检查过滤词
|
||||
file_name = file['file_name'].lower()
|
||||
file_ext = os.path.splitext(file_name)[1].lower().lstrip('.')
|
||||
|
||||
# 检查过滤词是否存在于文件名中,或者过滤词等于扩展名
|
||||
if not any(word in file_name for word in filterwords_list) and not any(word == file_ext for word in filterwords_list):
|
||||
filtered_files.append(file)
|
||||
else:
|
||||
# 文件检查过滤词
|
||||
file_name = file['file_name'].lower()
|
||||
file_ext = os.path.splitext(file_name)[1].lower().lstrip('.')
|
||||
|
||||
# 检查过滤词是否存在于文件名中,或者过滤词等于扩展名
|
||||
if not any(word in file_name for word in filterwords_list) and not any(word == file_ext for word in filterwords_list):
|
||||
filtered_files.append(file)
|
||||
|
||||
dir_file_list = filtered_files
|
||||
|
||||
# 使用一个列表收集所有需要重命名的操作
|
||||
rename_operations = []
|
||||
rename_logs = [] # 收集重命名日志
|
||||
|
||||
Loading…
Reference in New Issue
Block a user