From 3915c453e080e3b8a722dcea4488c83c6af70213 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 15 Apr 2021 00:10:19 +0300 Subject: [PATCH] Move processed images to separate directory --- picsorter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/picsorter.py b/picsorter.py index 5071fa1..2041136 100644 --- a/picsorter.py +++ b/picsorter.py @@ -8,11 +8,14 @@ from pathlib import Path import re import logging import time +import shutil +import os class PicSorter: def __init__(self): self.dir_tmp = Path('R:/') - self.dir_input = Path('./input') + self.dir_input = Path('R:/input') + self.dir_processed = Path('R:/processed') self.dir_logs = Path('./logs') self.dir_library = Path('./library') self.setup_folders() @@ -20,6 +23,7 @@ class PicSorter: def setup_folders(self): self.dir_tmp.mkdir(exist_ok=True) + self.dir_processed.mkdir(exist_ok=True) self.dir_logs.mkdir(exist_ok=True) self.dir_library.mkdir(exist_ok=True) @@ -60,6 +64,7 @@ class PicSorter: image_path, tags = meta_result library.move(image_path, tags) db.add(post_id, tags.tags_string) + shutil.move(os.fspath(filename), os.fspath(self.dir_processed)) time.sleep(5) except Exception as ex: raise ex