-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
102 lines (82 loc) · 2.72 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os,sys
import json
import shutil
import time
from organiser import Setup
def create_dir(name):
try:
os.mkdir(name)
except FileExistsError:
pass
def create_file(name):
try:
with open(name,"w+") as f_creator:
pass
except FileExistsError:
pass
def configure():
print("Lets configure ...")
pic = input("Pictures : ")
execu = input("Executables : ")
docu = input("Documents : ")
vids = input("Videos : ")
archive = input("Archived : ")
with open("details.json","w+") as file:
details_dict = {"Documents":docu,
"Pictures":pic,
"Executables":execu,
"Videos":vids,
"Archives":archive,
}
json.dump(details_dict,file)
path = input("Enter the Target Path : ")
file_organiser = Setup(path)
file_organiser.list_files()
pictures,videos,exes,documents,archives = file_organiser.group()
if os.path.isfile("details.json"):
pass
else:
configure()
with open("details.json","r") as file:
file_details = json.load(file)
create_dir(file_details["Executables"])
create_dir(file_details["Videos"])
create_dir(file_details["Pictures"])
create_dir(file_details["Documents"])
create_dir(file_details["Archives"])
pics_path = file_details["Pictures"]
vids_path = file_details["Videos"]
executables = file_details["Executables"]
documents_path = file_details["Documents"]
archive_path = file_details["Archives"]
for pics in pictures:
os.chdir(path)
abs_path = os.path.abspath(pics)
shutil.copyfile(abs_path,os.path.join(pics_path,pics))
os.unlink(abs_path)
print("[+] Done processing Pictures.... \n ")
for video in videos:
os.chdir(path)
abs_path = os.path.abspath(video)
shutil.copyfile(abs_path,os.path.join(vids_path,video))
os.unlink(abs_path)
print("[+] Done processing pictures .... \n")
for exe in exes:
os.chdir(path)
abs_path = os.path.abspath(exe)
shutil.copyfile(abs_path,os.path.join(executables,exe))
os.unlink(abs_path)
print("[+] Done Processing Executables.... \n")
for document in documents:
os.chdir(path)
abs_path = os.path.abspath(document)
shutil.copy(abs_path,os.path.join(documents_path,document))
os.unlink(abs_path)
print("[+] Done Processing Documents .... \n")
for arc in archives:
os.chdir(path)
abs_path = os.path.abspath(arc)
shutil.copy(abs_path,os.path.join(archive_path,arc))
os.unlink(abs_path)
print("[+] Done processing archives.... \n ")
print("[+] All tasks completed Sucessfully!")