FileBotROuGGy/filebot.py

26 lines
801 B
Python
Raw Normal View History

2022-01-26 17:13:42 +07:00
from glob import glob
import shutil
import os
2022-01-26 17:50:28 +07:00
from pathlib import Path
import subprocess
import re
2022-01-26 17:13:42 +07:00
2022-01-26 17:50:28 +07:00
source_path = Path('/mnt/Download/finished/')
dest_path = '/mnt/Download/PostProcess/'
2022-01-26 17:13:42 +07:00
2022-01-26 17:50:28 +07:00
for root, dirs, files in os.walk(source_path):
for dir in dirs:
for file in files:
rar_file = glob(f"{os.path.join(root, '')}*rar")
if rar_file:
subprocess.run(["/usr/bin/unrar", 'e', rar_file[0], '-idq', ''])
2022-01-26 17:13:42 +07:00
2022-01-26 17:50:28 +07:00
for root, dirs, files in os.walk(source_path):
for dir in dirs:
for file in files:
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))
for src_folder in source_path.iterdir():
shutil.move(src_folder, dest_path)