-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (32 loc) · 1.49 KB
/
main.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
import os
import shutil
files = os.listdir()
files.remove("main.py")
def createFolder(folderName):
if folderName not in os.listdir():
return os.makedirs(folderName)
def moveFile(fileName,folder):
for image in fileName:
shutil.move(image,folder)
imageExtension = [".jpg",".jpeg",".gif",".ai",".bmp",".ico",".png",".psd",".svg"]
audioExtension = [".wav",".mpa",".aif",".mp3"]
videoExtension = [".avi",".flv",".m4v",".mkv",".mov",".mp4",".mpg",".mpeg",".wmv",".swf",".vob"]
docExtension = [".doc",".odt",".pdf",".rtf",".tex",".txt",".wpd",".xls",".ods",".ppt",".pptx",".key",".odp",".pps"]
images = [file for file in files if os.path.splitext(file)[1].lower() in imageExtension]
video = [file for file in files if os.path.splitext(file)[1].lower() in videoExtension]
audio = [file for file in files if os.path.splitext(file)[1].lower() in audioExtension]
docs = [file for file in files if os.path.splitext(file)[1].lower() in docExtension]
other= []
for file in files:
xtension = os.path.splitext(file)[1].lower()
if xtension not in imageExtension and xtension not in videoExtension and xtension not in audioExtension and xtension not in docExtension and os.path.isfile(file):
other.append(file)
allFolders = ["Audio","Video","Images","Documents","Others"]
filetypes = ["audio","video","images","docs" ,"other"]
for f in allFolders:
createFolder(f)
moveFile(audio,"Audio")
moveFile(video,"Video")
moveFile(images,"Images")
moveFile(docs,"Documents")
moveFile(other,"Others")