-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile_Organiser.py
More file actions
30 lines (25 loc) · 779 Bytes
/
Copy pathFile_Organiser.py
File metadata and controls
30 lines (25 loc) · 779 Bytes
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
#!/usr/bin/python3
import os,shutil
def organiser(path):
os.chdir(path)
files=os.listdir()
extensions={
("pdf","docx","pptx"):"Files",
("zip","tar","rar"):"Archive",
("mp3","wav"):"Music",
("jpeg","jpg","img","png","heic"):"Images",
("mkv","mp4"):"Movies"
}
for i in files:
if os.path.isfile(i):
f=i.split(".")[-1]
for j,k in extensions.items():
if f in j:
#os.makedirs(k,exist_ok=True)
if not os.path.exists(k):
os.mkdir(k)
shutil.move(i, k)
print("Done!!")
if __name__=="__main__":
path=input("Give the path of the folder ou want to organise: ")
organiser(path)