-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_classification.py
More file actions
53 lines (39 loc) · 1.9 KB
/
Copy pathimage_classification.py
File metadata and controls
53 lines (39 loc) · 1.9 KB
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
"""This scripts organize multiple photos by year and folders. I use it because
i save all the photos of my cellphone by year."""
from utils.images_in_time_interval import images_in_time_interval
from datetime import datetime
import os
years = [2021, 2022, 2023, 2024]
folders = ["Camera", "Instagram", "Screenshots", "WhatsApp Images", "WhatsApp VIdeos"]
def create_folders(destination_folder, years, folders):
"""This fucntion create multiple folder to organize the photos and videos of your cellphone
by year and the typical foldeer find in your smartphone directories."""
# Create years folders
for year in years:
year_path = os.path.join(destination_folder, str(year))
os.mkdir(year_path)
# Create internal folders inside year
for folder in folders:
folder_path = os.path.join(year_path, folder)
os.mkdir(folder_path)
# WhatsApp diferientiate between sent and recived files
if folder == "WhatsApp Images" or folder == "WhatsApp Video":
sent_path = os.path.join(folder_path, "sent")
os.mkdir(sent_path)
###################################################################################################
years = [2021]
source_folder = r"C:\Users\marco\Escritorio\y9 2019 (viejo)"
destination_folder = r"D:\Fotos"
folders = os.listdir(source_folder) # List folders in source directory
# create_folders(destination_folder, years, folders)
for year in years:
year_folder = os.path.join(destination_folder, str(year))
for folder in folders:
print(folder.center(50, "-"))
images_in_time_interval(
source_folder=os.path.join(source_folder, folder),
destination_folder=os.path.join(year_folder, folder),
start_date=datetime(year=year, month=1, day=1),
end_date=datetime(year=year, month=12, day=31),
action="Copy",
)