forked from prashantsengar/ArrangePy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrange.py
More file actions
76 lines (64 loc) · 2.77 KB
/
Copy patharrange.py
File metadata and controls
76 lines (64 loc) · 2.77 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
#arrange.py
#Arranges the fiels according to their types for later classification
#uses shutil, os
import os
import shutil
def makeFolders(f):
if f in os.listdir():
return
os.mkdir(f'.\\{f}')
makeFolders('pPDF')
makeFolders('Pimages')
makeFolders('Pvideos')
makeFolders('Paudios')
makeFolders('Pprograms')
makeFolders('Pdocs')
def strong_arrange():
for foldername, subfolders, filenames in os.walk(folder):
for file in filenames:
if file.lower().endswith('.pPDF'):
print(file)
shutil.move(file,'.\\pPDF')
elif file.lower().endswith('png') or file.lower().endswith('jpg') or file.lower().endswith('jpeg') or file.lower().endswith('gif'):
print(file)
shutil.move(file,'.\\Pimages')
elif file.lower().endswith('.mp4') or file.lower().endswith('.mkv') or file.lower().endswith('.avi') or file.lower().endswith('.3gp'):
print(file)
shutil.move(file,'.\\Pvideos')
elif file.lower().endswith('.mp3') or file.lower().endswith('.wav'):
print(file)
shutil.move(file,'.\\Paudios')
def arrange():
for file in os.listdir(folder):
if file.lower().endswith('.pdf') :
print(file)
shutil.move(file,'.\\pPDF')
elif file.lower().endswith('png') or file.lower().endswith('jpg') or file.lower().endswith('jpeg') or file.lower().endswith('gif'):
print(file)
shutil.move(file,'.\\Pimages')
elif file.lower().endswith('.mp4') or file.lower().endswith('.mkv') or file.lower().endswith('.avi') or file.lower().endswith('.3gp'):
print(file)
shutil.move(file,'.\\Pvideos')
elif file.lower().endswith('.mp3') or file.lower().endswith('.wav'):
print(file)
shutil.move(file,'.\\Paudios')
elif file.lower().endswith('.exe'):
print(file)
shutil.move(file,'.\\Pprograms')
elif (file.lower().endswith('.docx') or file.lower().endswith('.doc') or
file.lower().endswith('.xlsx') or file.lower().endswith('.xls') or
file.lower().endswith('.txt') or file.lower().endswith('.csv') or
file.lower().endswith('.pptx') or file.lower().endswith('.ppt')):
print(file)
shutil.move(file,'.\\Pdocs')
if __name__ == '__main__':
print("Arrange files")
folder=os.getcwd()
print(folder)
choice = int(input("Press 1 for Weak arrange\nPress 2 for Strong arrange\n0 to exit"))
if choice==1:
arrange()
if choice==2:
strong_arrange()
if choice==0:
exit(0)