This repository has been archived by the owner on Jul 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amu.py
80 lines (64 loc) · 3.26 KB
/
amu.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
import shutil
import sys
import os
#==========================================================================================#
# >>>>> ПРОВЕРКА ВЕРСИИ PYTHON <<<<< #
#==========================================================================================#
# Минимальная требуемая версия Python.
PythonMinimalVersion = (3, 9)
# Проверка соответствия.
if sys.version_info < PythonMinimalVersion:
sys.exit("Python %s.%s or later is required.\n" % PythonMinimalVersion)
#==========================================================================================#
# >>>>> ОБРАБОТКА ФАЙЛОВ <<<<< #
#==========================================================================================#
# Если передан один аргумент.
if len(sys.argv) == 2:
# Вывод в консоль: в процессе.
print("In progress...")
# Обрабатываемая директория (с заменой слэшей для совместимости с Linux).
AppLockFolder = sys.argv[1].replace('\\', '/')
# Получение списка папок.
DirectoryContent = os.listdir(sys.argv[1] + "/dont_remove")
# Список папок.
FoldersList = list()
# Список изображений.
ImagesList = list()
# Список видео.
VideosList = list()
# Сохранить названия папок.
for Something in DirectoryContent:
if os.path.isdir(AppLockFolder + "/dont_remove/" + Something):
FoldersList.append(Something)
# Для каждой папки.
for Folder in FoldersList:
# Получить список локальных изображений.
LocalImagesList = os.listdir(AppLockFolder + "/dont_remove/" + Folder + "/.image")
# Получить список локальных видео.
LocalVideosList = os.listdir(AppLockFolder + "/dont_remove/" + Folder + "/.video")
# Поместить все локальные изображения в глобальный список.
for Image in LocalImagesList:
ImagesList.append(AppLockFolder + "/dont_remove/" + Folder + "/.image/" + Image)
# Поместить все локальные видео в глобальный список.
for Video in LocalVideosList:
VideosList.append(AppLockFolder + "/dont_remove/" + Folder + "/.video/" + Image)
# Если найдены изображения.
if len(ImagesList) > 0:
# Если не существует папки для изображений, то создать её.
if os.path.exists("Images") == False:
os.makedirs("Images")
# Переместить каждый файл с переименованием.
for Image in ImagesList:
shutil.copy(Image, "Images/" + Image.split('/')[-1] + ".jpg")
# Если найдены видео.
if len(VideosList) > 0:
# Если не существует папки для изображений, то создать её.
if os.path.exists("Videos") == False:
os.makedirs("Videos")
# Скопировать каждый файл с переименованием.
for Video in VideosList:
shutil.copy(Image, "Videos/" + Image.split('/')[-1] + ".mp4")
else:
raise Exception("Invalid arguments count.")
# Завершение работы скрипта.
sys.exit(0)