-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
134 lines (123 loc) · 3.19 KB
/
main.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from os.path import expanduser, isabs
from colorama import init, Fore, Style
from file_organizer import sort_files
# Инициализация colorama
init()
# Расширения файлов для каждой категории
extensions = {
"video": [
"mp4",
"mov",
"avi",
"mkv",
"wmv",
"3gp",
"3g2",
"mpg",
"mpeg",
"m4v",
"h264",
"flv",
"rm",
"swf",
"vob",
],
"code": ["py", "js", "html", "jar", "json", "java", "cpp", "css", "php"],
"data": [
"sql",
"sqlite",
"sqlite3",
"csv",
"dat",
"db",
"log",
"mdb",
"sav",
"tar",
"xml",
"xlsx",
"xls",
"xlsm",
"ods",
],
"audio": [
"mp3",
"wav",
"ogg",
"flac",
"aif",
"mid",
"midi",
"mpa",
"wma",
"wpl",
"cda",
"aac",
"m4a",
],
"image": [
"jpg",
"png",
"bmp",
"ai",
"psd",
"ico",
"jpeg",
"ps",
"svg",
"tif",
"tiff",
"gif",
"eps",
],
"archive": [
"zip",
"rar",
"7z",
"z",
"gz",
"rpm",
"arj",
"pkg",
"deb",
"tar.gz",
"tar.bz2",
],
"text": ["pdf", "txt", "doc", "docx", "rtf", "tex", "wpd", "odt"],
"presentation": ["pptx", "ppt", "pps", "key", "odp"],
"font": ["otf", "ttf", "fon", "fnt"],
"installer": ["torrent", "msi", "exe"],
"mobile": ["apk", "obb"],
"different": ["mcaddon", "mcpack", "ct"],
"backup": ["bak", "bak2"],
"other": []
}
def main():
# Путь к папке по умолчанию
link_path_def = expanduser("~\\Downloads")
print(f"\n{Fore.YELLOW}------- Начало работы -------{Style.RESET_ALL}")
"""
Основная функция программы.
"""
print("1) Введите путь к папке.")
print("2) Нажмите enter, чтобы оставить путь к папке Download.")
main_path = ""
while not main_path:
main_path = input("Путь к папке: ").strip().replace("'", "").replace('"', "")
if not main_path:
main_path = link_path_def
print(f"{Fore.GREEN}Выбрана папка Download!{Style.RESET_ALL} \n")
else:
if not isabs(main_path):
print(
f"{Fore.RED}Введенный путь не является действительным. Попробуйте снова.{Style.RESET_ALL}"
)
main_path = ""
sort_files(main_path, extensions)
print(f"{Fore.YELLOW}------- Конец работы -------{Style.RESET_ALL}")
if __name__ == "__main__":
while True:
main()
choice = input("\n Желаете продолжить? (y/n): ")
if choice.lower() not in ["y", "н"]:
break