This repository was archived by the owner on Apr 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleaner.py
More file actions
38 lines (32 loc) · 1.44 KB
/
Copy pathcleaner.py
File metadata and controls
38 lines (32 loc) · 1.44 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
import shutil
import os
#change 'justin' to desired user on computer
screenshot_dir = '/Users/justin/Desktop/ss' #'ss' for screenshots folder
desktop_dir = '/Users/justin/Desktop'
months = {'01': 'January', '02': 'February', '03': 'March', '04': 'April', '05': 'May',
'06': 'June', '07': 'July', '08': 'August', '09': 'September','10': 'October',
'11': 'November', '12': 'December'}
# creates screenshot folder if it doesn't exist already
if not os.path.exists(screenshot_dir):
os.makedirs(screenshot_dir)
print('Created folder ss')
# checks for screenshots specifically
files_ond_desktop = os.listdir(desktop_dir)
for file in files_ond_desktop:
if file.startswith('Screen Shot') and file.endswith('.png'):
file_path = desktop_dir + '/' + file
file_year = file[12:16]
# Create year directory if it doesn't exist
year_dir = screenshot_dir + '/' + file_year
if not os.path.exists(year_dir):
os.makedirs(year_dir)
print(f'Created folder: {year_dir}')
# Extract month from the filename
file_month = file[17:19]
# Create month directory within the year directory
month_dir = year_dir + '/' + months[file_month]
if not os.path.exists(month_dir):
os.makedirs(month_dir)
print(f'Created folder: {month_dir}')
shutil.move(file_path, month_dir)
print(f'Moved {file} to \n{month_dir}...')