-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (38 loc) · 1.57 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
import os
from pathlib import Path
import shutil
def get_current_working_directory() -> Path:
return Path.cwd()
def get_file_names():
return os.listdir(pwd)
def put_in_img_dir(file):
pwd = get_current_working_directory()
docFilePath = pwd / 'S-Images'
try:
if not os.path.exists(docFilePath):
os.mkdir('S-Images')
shutil.move(str(pwd / file), str(docFilePath))
except Exception as e:
print('Encountered a error: ', e)
def put_in_doc_dir(file):
pwd = get_current_working_directory()
docFilePath = pwd / 'S-Docs'
try:
if not os.path.exists(docFilePath):
os.mkdir('S-Docs')
shutil.move(str(pwd / file), str(docFilePath))
except Exception as e:
print('Encountered a error: ', e)
if __name__ == '__main__':
pwd = get_current_working_directory()
files = get_file_names()
for file in files:
path = pwd / file
if os.path.isdir(path):
continue
if '.png' in file:
put_in_img_dir(file)
elif file.endswith('.pdf'):
put_in_doc_dir(file)
elif file.endswith('.txt'):
put_in_doc_dir(file)