-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.py
65 lines (58 loc) · 2.56 KB
/
helper.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
from modules.log_utils import clear_terminal, get_error_with_time, get_log_header_with_time, input_with_time
from modules.combine_utils import combine_pdfs_to_pdf, combine_subfolders_images_to_pdfs
from modules.file_utils import move_files_to_subfolders, rename_files, remove_subfolders
from modules.pdf_utils import compress_pdfs, convert_cbz_to_pdf
from modules.print_utils import print_info, print_menu
def get_directory_path():
while True:
directory_path = input_with_time("directory path").strip()
if os.path.exists(directory_path) and os.path.isdir(directory_path):
return directory_path
else:
print(get_error_with_time(f"Invalid directory path: '{directory_path}'. Please try again."))
def main():
print(get_log_header_with_time("Hello! Let's get started."))
directory_path = get_directory_path()
while True:
try:
clear_terminal(directory_path)
print_menu()
choice = input_with_time("your choice")
clear_terminal(directory_path)
if choice == "1":
print_info()
elif choice == "2":
directory_path = get_directory_path()
elif choice == "3":
rename_files(directory_path)
clear_terminal(directory_path)
move_files_to_subfolders(directory_path)
clear_terminal(directory_path)
convert_cbz_to_pdf(directory_path)
clear_terminal(directory_path)
compress_pdfs(directory_path)
clear_terminal(directory_path)
remove_subfolders(directory_path)
elif choice == "4":
rename_files(directory_path)
elif choice == "5":
move_files_to_subfolders(directory_path)
elif choice == "6":
convert_cbz_to_pdf(directory_path)
elif choice == "7":
compress_pdfs(directory_path)
elif choice == "8":
remove_subfolders(directory_path)
elif choice == "9":
combine_pdfs_to_pdf(directory_path)
elif choice == "10":
combine_subfolders_images_to_pdfs(directory_path)
else:
print(get_error_with_time("Invalid choice. Please enter a valid number."))
except KeyboardInterrupt:
break
except Exception as e:
print(get_error_with_time(e))
if __name__ == "__main__":
main()