forked from shenxianmq/MediaHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path根据tmdbid查重.py
43 lines (39 loc) · 1.34 KB
/
根据tmdbid查重.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import re
import shutil
import traceback
tmdb_list = []
# 这个是基准电影库
base_dir = "/Users/shenxian/CloudNAS/CloudDrive2/115/看剧/影视合集/电影/4K Remux"
for root, dirs, files in os.walk(base_dir):
for dir in dirs:
if "tmdb" in dir:
tmdbid = re.findall(r"tmdb.*?(\d+)", dir)
tmdb_list.append(tmdbid[0])
num = 0
# # 这个是基准电影库
# base_dir = "/Users/shenxian/CloudNAS/CloudDrive2/115/abc"
# for root, dirs, files in os.walk(base_dir):
# for dir in dirs:
# if "tmdb" in dir:
# tmdbid = re.findall(r"tmdb.*?(\d+)", dir)
# tmdb_list.append(tmdbid[0])
# 这里面填你要查重的电影库
target_dir_list = [
"/Users/shenxian/CloudNAS/CloudDrive2/115/abc",
]
for root_dir in target_dir_list:
for root, dirs, files in os.walk(root_dir):
for dir in dirs:
if "tmdb" in dir:
tmdbid = re.findall(r"tmdb.*?(\d+)", dir)
if tmdbid[0] in tmdb_list:
num += 1
dir_path = os.path.join(root, dir)
try:
shutil.rmtree(dir_path)
print(f"dir deleted::: {dir}")
except:
print(f"error::: {dir_path}")
print(traceback.format_exc())
print(num)