-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory_ui.py
More file actions
173 lines (153 loc) · 5.55 KB
/
Directory_ui.py
File metadata and controls
173 lines (153 loc) · 5.55 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import os
import shutil
from tkinter import *
window = Tk()
window.geometry('300x93')
window.title('File Management')
window.config(bg='lightblue')
Label(text='Done!\n Now close window..',font=('blod',20), bg='green',fg='lightblue').grid(row=2,column=2)
#input from user
input_file_path = os.getcwd()
#file path join
pdf_join_path = os.path.join(input_file_path,'PDF')
video_join_path = os.path.join(input_file_path,'VIDEOS')
image_join_path = os.path.join(input_file_path,'IMAGES')
pptx_join_path = os.path.join(input_file_path,'PPT')
exe_join_path = os.path.join(input_file_path,'PROGRAM')
txt_join_path = os.path.join(input_file_path,'TEXT')
def pdf():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'pdf' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path,file_name)
total_new_file_path = os.path.join(pdf_join_path,file_name)
shutil.move(total_file_path,total_new_file_path)
def mp4():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'mp4' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path,file_name)
total_new_file_path = os.path.join(video_join_path,file_name)
shutil.move(total_file_path,total_new_file_path)
def mkv():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'mkv' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path, file_name)
total_new_file_path = os.path.join(video_join_path, file_name)
shutil.move(total_file_path, total_new_file_path)
def jpg():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'jpg' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path, file_name)
total_new_file_path = os.path.join(image_join_path, file_name)
shutil.move(total_file_path, total_new_file_path)
def jpeg():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'jpeg' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path, file_name)
total_new_file_path = os.path.join(image_join_path, file_name)
shutil.move(total_file_path, total_new_file_path)
def png():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'png' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path, file_name)
total_new_file_path = os.path.join(image_join_path, file_name)
shutil.move(total_file_path, total_new_file_path)
def pptx():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'pptx' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path, file_name)
total_new_file_path = os.path.join(pptx_join_path, file_name)
shutil.move(total_file_path, total_new_file_path)
def exe():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'exe' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path, file_name)
total_new_file_path = os.path.join(exe_join_path, file_name)
shutil.move(total_file_path, total_new_file_path)
def txt():
location = os.listdir(input_file_path)
len_location = len(location)
for i in range(len_location):
if 'txt' in location[i]:
file_name = location[i]
total_file_path = os.path.join(input_file_path,file_name)
total_new_file_path = os.path.join(txt_join_path,file_name)
shutil.move(total_file_path,total_new_file_path)
def video_choice():
check_Video_folder = os.path.exists(video_join_path)
if check_Video_folder==False:
os.makedirs(video_join_path)
mp4()
mkv()
else:
mp4()
mkv()
video_choice()
def image_choice():
check_image_folder = os.path.exists(image_join_path)
if check_image_folder==False:
os.makedirs(image_join_path)
jpeg()
jpg()
png()
else:
jpeg()
jpg()
png()
image_choice()
def pdf_choice():
check_pdf_folder = os.path.exists(pdf_join_path)
if check_pdf_folder==False:
os.makedirs(pdf_join_path)
pdf()
else:
pdf()
pdf_choice()
def pptx_choice():
check_pptx_folder = os.path.exists(pptx_join_path)
if check_pptx_folder == False:
os.makedirs(pptx_join_path)
pptx()
else:
pptx()
pptx_choice()
def exe_choice():
check_exe_folder = os.path.exists(exe_join_path)
if check_exe_folder == False:
os.makedirs(exe_join_path)
exe()
else:
exe()
exe_choice()
def txt_choice():
check_txt_folder = os.path.exists(txt_join_path)
if check_txt_folder == False:
os.makedirs(txt_join_path)
txt()
else:
txt()
txt_choice()
window.mainloop()