-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaking_pasts
More file actions
47 lines (37 loc) · 1.45 KB
/
Copy pathMaking_pasts
File metadata and controls
47 lines (37 loc) · 1.45 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
'''
Esse script gera pastas com o nome do dia em que ele for executado e caso exista uma do dia passado ele move a pasta para
uma pasta do ano atual.
This script generates folders with the name of the day it runs and if there is one from last day it moves the folder to
a folder also from the current year.
'''
import os, datetime, shutil
hoje = datetime.date.today()
nome = hoje
setnome = str(hoje)
year = setnome[:4]
name = setnome[5:]
User = input('Enter computer user: ')
cont = 0
# Criando o nome para mover a última pasta criada / Creating name to move to last folder created
while True:
hoje -= datetime.timedelta(days=1)
nomemover = str(hoje)
oi = nomemover[5:]
if os.path.exists(f'C:/Users/{User}/Pictures/{nomemover[5:]}'):
break
else:
cont += 1
if cont == 1000:
break
# Criando pasta do ano atual / Creating current year dir
if not os.path.exists(f'C:/Users/{User}/Pictures/{year}'):
os.mkdir(f'C:/Users/{User}/Pictures/{year}')
# Movendo pasta / Moving dir
if os.path.exists(f'C:/Users/{User}/Pictures/{oi}'):
shutil.move(f'C:/Users/{User}/Pictures/{oi}',
f'C:/Users/{User}/Pictures/{year}')
# Criando pasta do dia atual / Creating current day folder
if not os.path.exists(f'C:/Users/{User}/Pictures/{name}'):
os.mkdir(f'C:/Users/{User}/Pictures/{name}')
if os.path.exists(f'C:/Users/{User}/Pictures/{name}'):
os.mkdir(f'C:/Users/{User}/Pictures/{name}/pronto')