-
Notifications
You must be signed in to change notification settings - Fork 0
/
organize_directory.py
39 lines (29 loc) · 1.21 KB
/
organize_directory.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
import os
import shutil
import sys
current_dir = os.getcwd()
for name_of_file in os.listdir(current_dir):
if name_of_file.endswith((".png" , "jpg","jpeg","gif")):
if not os.path.exists("Images"):
os.mkdir("Images")
shutil.move(name_of_file, "Images")
print("Image moved successfully")
for name_of_file in os.listdir(current_dir):
if name_of_file.endswith((".mp4" , ".mkv",".avi",".flv")):
if not os.path.exists("Videos"):
os.mkdir("Videos")
shutil.move(name_of_file, "Videos")
print("Video moved successfully")
for name_of_file in os.listdir(current_dir):
if name_of_file.endswith((".pdf" , ".docx",".doc",".txt")):
if not os.path.exists("Documents"):
os.mkdir("Documents")
shutil.move(name_of_file, "Documents")
print("Document moved successfully")
for name_of_file in os.listdir(current_dir):
if name_of_file.endswith((".zip" , ".rar",".tar",".gz")):
if not os.path.exists("Archives"):
os.mkdir("Archives")
shutil.move(name_of_file, "Archives")
print("Archives moved successfully")
print("All files are organized successfully")