1
0
mirror of https://gist.github.com/6ba37e4d4084e858f917e271550ce5f6.git synced 2024-09-20 00:34:20 +03:00

Move processed images to separate directory

This commit is contained in:
Victor 2021-04-15 00:10:19 +03:00
parent 5e22d1d9a6
commit 3915c453e0

View File

@ -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