-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenhance_dir.py
30 lines (25 loc) · 1.06 KB
/
enhance_dir.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
from helpers import is_hidden
from enhance_single import enhance_comic
import os
from app_logging import app_logger
import sys
def enhance_directory(directory):
"""
Processes all files (no subdirectories) in the given directory by calling
enhance_comic(file_path) on each file. Only files directly in 'directory_path'
will be processed—no subdirectories are traversed.
"""
# List all files in the directory (not diving into subdirectories).
for filename in os.listdir(directory):
file_path = os.path.join(directory, filename)
# Skip hidden files or directories. Then ensure we are only processing files.
if not is_hidden(file_path) and os.path.isfile(file_path):
enhance_comic(file_path)
if __name__ == "__main__":
# The directory path is passed as the first argument
if len(sys.argv) < 2:
app_logger.info("No directory provided!")
else:
directory = sys.argv[1]
enhance_directory(directory)
app_logger.info(f"Enhance Images starting for directory: {directory}")