-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganiser.py
70 lines (53 loc) · 2.01 KB
/
organiser.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
import os
import json
class Setup:
def __init__(self,absolute_path):
self.path = absolute_path
def list_files(self):
files_list = []
for file_name in os.listdir(self.path):
result = os.path.isfile(file_name)
if not result:
files_list.append(file_name)
with open("info.json","w+") as file:
json.dump(files_list,file)
file.close()
def group(self):
with open("info.json","r") as file:
details = json.load(file)
#print(details)
os.remove("info.json")
doc = [".docx",".pdf",".pptx"]
executables = [".exe",".bat",".ova"]
pics = [".jpg",".jpeg",".png"]
vids = [".mp3",".mp4",".avi"]
archived = [".zip",".tar.xz"]
doc_files = []
exe_files = []
pic_files = []
vid_files = []
arc_files = []
for file_name in details:
for extension in doc:
#print(extension)
if file_name.endswith(extension):
#print(file_name)
doc_files.append(file_name)
break
for extension in executables:
if file_name.endswith(extension):
exe_files.append(file_name)
break
for extension in pics:
if file_name.endswith(extension):
pic_files.append(file_name)
break
for extension in vids:
if file_name.endswith(extension):
vid_files.append(file_name)
break
for extension in archived:
if file_name.endswith(extension):
arc_files.append(file_name)
break
return pic_files,vid_files,exe_files,doc_files,arc_files