-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
59 lines (46 loc) · 2.03 KB
/
test.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
import os
from pathlib import Path
import tkinter as tk
DIRECTORIES = {
"WEB-RELATED": [".html5", ".html", ".htm", ".xhtml",".css","scss",".css3"],
"IMAGES": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg", ".heif", ".psd", ".ai", ".ico"],
"VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng", ".qt", ".mpg", ".mpeg", ".3gp"],
"DOCUMENTS": [".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods", ".odt", ".pwi", ".xsn", ".xps", ".dotx",
".docm", ".dox", ".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt", "pptx"],
"ARCHIVES": [".a", ".ar", ".cpio", ".iso", ".tar", ".gz", ".rz", ".7z", ".dmg", ".rar", ".xar", ".zip"],
"AUDIO": [".aac", ".aa", ".aac", ".dvf", ".m4a", ".m4b", ".m4p", ".mp3", ".msv", "ogg", "oga", ".raw", ".vox",
".wav", ".wma"],
"PLAINTEXT": [".txt", ".in", ".out"],
"PDF": [".pdf"],
"CODING": [".py",".js",".c",".cc"],
"XML": [".xml"],
"EXE": [".exe"],
"SCRIPTS": [".sh",".bat"]
}
FILE_FORMATS = {file_format: directory
for directory, file_formats in DIRECTORIES.items()
for file_format in file_formats}
def organize_junk():
for entry in os.scandir():
if entry.is_dir():
continue
file_path = Path(entry)
file_format = file_path.suffix.lower()
if file_format in FILE_FORMATS:
directory_path = Path(FILE_FORMATS[file_format])
directory_path.mkdir(exist_ok=True)
file_path.rename(directory_path.joinpath(file_path))
for dir in os.scandir():
try:
os.rmdir(dir)
except:
pass
window = tk.Tk()
window.title("Auto-Organizer")
window.iconbitmap("./icon.ico")
window.geometry("400x400")
title = tk.Label(window, text="Auto-Organizer by Ryan", font=("Arial", 16))
title.pack()
button = tk.Button(window, text="Start the Organizing", command=organize_junk)
button.pack()
window.mainloop()