Skip to content

Commit eebd260

Browse files
committed
增加ignore_file_count_check参数,可忽略旧文件数量和新文件数量不一致的检查
1 parent 775d738 commit eebd260

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

EpisodeReName.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
use_folder_as_season = 0
100100
del_empty_folder = 0
101101
priority_match = 0
102+
ignore_file_count_check = 0
102103
else:
103104
# 新的argparse解析
104105
# python EpisodeReName.py --path E:\test\极端试验样本\S1 --delay 1 --overwrite 1
@@ -177,6 +178,13 @@
177178
type=int,
178179
default=0,
179180
)
181+
ap.add_argument(
182+
'--ignore_file_count_check',
183+
required=False,
184+
help='忽略旧文件数量和新文件数量不一致的检查,即使可能会覆盖文件也继续执行。默认为0不开启, 1是开启',
185+
type=int,
186+
default=0,
187+
)
180188

181189
args = vars(ap.parse_args())
182190
target_path = args['path']
@@ -190,6 +198,7 @@
190198
use_folder_as_season = args['use_folder_as_season']
191199
del_empty_folder = args['del_empty_folder']
192200
priority_match = args['priority_match']
201+
ignore_file_count_check = args['ignore_file_count_check']
193202

194203
if parse_resolution:
195204
name_format = 'S{season}E{ep} - {resolution}'
@@ -349,13 +358,20 @@
349358

350359
# 检查旧的文件数量和新的文件数量是否一致,防止文件被覆盖
351360
new_set = set([x[1] for x in file_lists])
352-
if len(new_set) != len(file_lists):
361+
if len(new_set) != len(file_lists) and not ignore_file_count_check:
353362
logger.warning(f"{'旧文件数量和新文件数量不一致,可能会被覆盖。请检查文件命名'}")
354363
new_list = [x[1] for x in file_lists]
355364
for file in new_set:
356365
if new_list.count(file) > 1:
357366
logger.warning(f"{'重复文件', file}")
367+
logger.info(f"{'如需忽略此检查,请使用 --ignore_file_count_check 1 参数'}")
358368
sys.exit()
369+
elif len(new_set) != len(file_lists) and ignore_file_count_check:
370+
logger.warning(f"{'旧文件数量和新文件数量不一致,可能会被覆盖。已启用忽略检查,继续执行'}")
371+
new_list = [x[1] for x in file_lists]
372+
for file in new_set:
373+
if new_list.count(file) > 1:
374+
logger.warning(f"{'重复文件', file}")
359375

360376
# 错误记录
361377
error_logs = []

0 commit comments

Comments
 (0)