Skip to content

Commit 0b47e42

Browse files
Clean the Clutter!
If you are not able to keep your folders clean and your files are also spread in the folder then This Python Program is for you!! This is a python utility that keeps your folders well cleaned & you can clear clutter of your spread files!! You just want to run this program & this python program make your all files in a managed way in folders and clean the clutter of your files!! 👍👍
1 parent a14841e commit 0b47e42

File tree

12 files changed

+80
-0
lines changed

12 files changed

+80
-0
lines changed

Clear the Clutter/Busy.ani

483 KB
Binary file not shown.

Clear the Clutter/ClutterTube.mhtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello

Clear the Clutter/coding.jpg

207 KB
Loading

Clear the Clutter/console.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a file with extension of .log named console.log

Clear the Clutter/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Hello world");

Clear the Clutter/main.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
3+
# createIfNotExist function which makes folder if not created
4+
def createIfNotExist(folder):
5+
if not os.path.exists(folder):
6+
os.mkdir(folder)
7+
8+
def extractFileCat(dictCat):
9+
return [file for file in files if os.path.splitext(file)[1].lower() in file_extensions[dictCat]]
10+
11+
def move(folderName, files):
12+
for file in files:
13+
os.replace(file, f"{folderName}/{file}")
14+
15+
16+
if __name__ == "__main__":
17+
18+
# Listing all the files
19+
files = os.listdir()
20+
files.remove("main.py")
21+
22+
# Creating folder if not exists
23+
createIfNotExist("Images")
24+
createIfNotExist("Text Files")
25+
createIfNotExist("Documents")
26+
createIfNotExist("Media")
27+
createIfNotExist("Code Files")
28+
createIfNotExist("Others")
29+
30+
# All Extensions
31+
file_extensions = {
32+
"ImageExtensions" : [".jpg", ".png", ".jpeg", ".gif", ".webp"],
33+
"TextExtensions" : [".txt", ".log"],
34+
"DocsExtensions" : [".docs", ".doc", ".docx", ".pptx", ".xlsx", ".csv"],
35+
"MediaExtensions" : [".mp4", ".mp3", ".vlf"],
36+
"CodeExtensions" : [".c", ".cpp", ".js", ".html", ".css", ".java"]
37+
}
38+
39+
# Extracting Files for particular category
40+
images = extractFileCat("ImageExtensions")
41+
textf = extractFileCat("TextExtensions")
42+
docs = extractFileCat("DocsExtensions")
43+
medias = extractFileCat("MediaExtensions")
44+
codes = extractFileCat("CodeExtensions")
45+
46+
#Other Files Logic
47+
others = []
48+
f2 = images + textf + docs + medias + codes
49+
for file in files:
50+
if file not in f2 and os.path.isfile(file):
51+
others.append(file)
52+
53+
# Adding all the files on its respective folder
54+
move("Images", images)
55+
move("Text Files", textf)
56+
move("Documents", docs)
57+
move("Media", medias)
58+
move("Code Files", codes)
59+
move("Others", others)
60+

Clear the Clutter/ppt.pptx

32.3 KB
Binary file not shown.

Clear the Clutter/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body{
2+
background: #000;
3+
}

Clear the Clutter/testing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a text file

Clear the Clutter/testing2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is testing 2 clutter

0 commit comments

Comments
 (0)