-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrmClutter.py
72 lines (57 loc) · 2.47 KB
/
rmClutter.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
61
62
63
64
65
66
67
68
69
70
71
72
import os
def createDir(folder):
if not os.path.exists(folder):
os.makedirs(folder)
def move(dirName, files):
if len(files) == 0:
pass
else:
for file in files:
os.replace(file, f"{dirName}/{file}")
if __name__ == "__main__":
files = os.listdir()
files.remove('rmClutter.py')
def fileRemove(fileName):
if fileName in files:
files.remove(fileName)
else:
pass
fileRemove('.gitignore')
fileRemove('.git')
fileRemove('.readme.md')
imgExts = ['.png', '.jpg', '.jpeg', '.svg', '.gif', '.raw', '.ico']
images = [file for file in files if os.path.splitext(file)[1].lower() in imgExts]
mediaExts = ['.mp4', '.mkv', '.mov', '.wnv', '.flv', '.avi', '.avchd', '.webm', 'mp4']
media = [file for file in files if os.path.splitext(file)[1].lower() in mediaExts]
docExts = ['.doc', '.docx', '.odt', '.pdf', '.xls', '.xlsx', '.ods', '.ppt', '.pptx', '.txt', '.odg', '.odp']
docs = [file for file in files if os.path.splitext(file)[1].lower() in docExts]
executableExts = ['.exe', '.deb', '.osx', '.ex', '.apk', '.bat', '.cmd', '.msi', '.sh', '.jar', '.appimage']
executables = [file for file in files if os.path.splitext(file)[1].lower() in executableExts]
zipExts = ['.zip', '.7z', '.rar', '.zipx', '.tar', '.gz']
zipFiles = [file for file in files if os.path.splitext(file)[1].lower() in zipExts]
codeExts = ['.py', '.htm', '.html', '.c', '.p', '.css', '.js', '.cc', '.go', 'swift', 'r', '.ru', '.db', '.sqlite', '.sqlite3', '.dbms', '.java']
code = [file for file in files if os.path.splitext(file)[1].lower() in codeExts]
otherExts = []
for file in files:
ext = os.path.splitext(file)[1].lower()
if ext not in imgExts and ext not in mediaExts and ext not in docExts and ext not in executableExts and ext not in zipExts and ext not in codeExts and os.path.isfile(file):
otherExts.append(file)
def fileCheck(filePack, dirName):
if len(filePack) == 0:
return None
else:
createDir(dirName)
fileCheck(images, 'images')
fileCheck(media, 'media')
fileCheck(docs, 'docs')
fileCheck(executables, 'executables')
fileCheck(zipFiles, 'zip-files')
fileCheck(code, 'code')
fileCheck(otherExts, 'others')
move('images', images)
move('media', media)
move('docs', docs)
move('executables', executables)
move('zip-files', zipFiles)
move('code', code)
move('others', otherExts)