-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFile_sorter.py
60 lines (47 loc) · 1.51 KB
/
File_sorter.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
#File Sorter by Mahesh Sawant
import os,shutil
s=os.chdir("Downloads")
current = os.getcwd()
files=os.listdir(current)
images=[".jpeg",".png",".jpg",".gif"] #extensions for images
text=[".doc",".txt",".pdf",".xlsx",".docx",".xls",".rtf"] #extensions for text files
videos=[".mp4",".mkv"] #extensions for videos
sounds=[".mp3",".wav",".m4a"] #extensions for sounds
applications=[".exe",".lnk"] #extensions for applications
codes = [".c",".py",".java",".cpp",".js",".html",".css",".php"] #extensions for codes
print("Sorting the files...")
for file in files:
dest = ""
for ex in images:
if file.endswith(ex):
dest='../Images'
shutil.move(file,dest)
break
for ex in text:
if file.endswith(ex):
dest='../Text'
shutil.move(file,dest)
break
for ex in sounds:
if file.endswith(ex):
dest='../Sounds'
shutil.move(file,dest)
break
for ex in videos:
if file.endswith(ex):
dest='../Videos'
shutil.move(file,dest)
break
for ex in applications:
if file.endswith(ex):
dest= '../Applications'
shutil.move(file,dest)
break
for ex in codes:
if file.endswith(ex):
dest= '../Codes'
shutil.move(file,dest)
break
if dest == "":
shutil.move(file,'../Others')
print("Sorting Completed...")