This commit is contained in:
Gregory Salaun 2022-01-26 18:21:52 +07:00
parent 98e0557bb9
commit a65a22ce51

View File

@ -10,6 +10,12 @@ import re
source_path = Path('/mnt/Download/finished/') source_path = Path('/mnt/Download/finished/')
dest_path = '/mnt/Download/PostProcess/' dest_path = '/mnt/Download/PostProcess/'
section_folders = ['4K-Movies', '4K-Series', 'Movies', 'Series', '']
# source_path = 'C:/Test/finished'
# dest_path = "C:/Test/PostProcess"
print("Checking if rar files and unraring...") print("Checking if rar files and unraring...")
for root, dirs, files in os.walk(source_path): for root, dirs, files in os.walk(source_path):
for dir in dirs: for dir in dirs:
@ -25,6 +31,9 @@ for root, dirs, files in os.walk(source_path):
if re.search(r'\.r\d{2,3}', file) or file.endswith('.rar') or file.endswith('.sfv') or file.endswith('.nfo'): if re.search(r'\.r\d{2,3}', file) or file.endswith('.rar') or file.endswith('.sfv') or file.endswith('.nfo'):
os.remove(os.path.join(root, file)) os.remove(os.path.join(root, file))
print(f"Moving files from {source_path} to {dest_path}") for root, dirs, files in os.walk(source_path):
for src_folder in source_path.iterdir(): for dir in dirs:
shutil.move(src_folder, dest_path) if dir not in section_folders:
match = re.search(r'.*\/(.*)', root)
section_path = match.group(1)
shutil.move(os.path.join(root, dir), os.path.join(dest_path, section_path))