Last active
May 12, 2025 19:47
-
-
Save MalikAbuShabab/820d0d5a7e115c8809ccd98cb994a1db to your computer and use it in GitHub Desktop.
Script organizing files and dividing them into folders according to their type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
home_path = os.getcwd() | |
print("\t [+] Welcome in organize.py script - happy clean folder ;) \n") | |
images = 0 | |
Code = 0 | |
Docs = 0 | |
archive = 0 | |
for file in os.listdir(home_path): | |
# organize images into Images folder | |
if file.endswith(("png", "jpg", "git", "jpeg")): | |
if not os.path.exists("Images"): | |
os.mkdir("Images") | |
shutil.move(file, "Images") | |
images = images + 1 | |
# organize Code file into Codes folder | |
elif file.endswith(("py", "java", "php", "js", "exe", "css", "sh", "bash", "html")): | |
if file != "organize.py": | |
if not os.path.exists("Codes"): | |
os.mkdir("Codes") | |
shutil.move(file, "Codes") | |
Code = Code + 1 | |
# organize Docs file into Documents folder | |
elif file.endswith(("pdf", "txt", "ppt", "docx", "pptx")): | |
if not os.path.exists("Docs"): | |
os.mkdir("Docs") | |
shutil.move(file, "Docs") | |
Docs = Docs + 1 | |
# organize archive file into archives folder | |
elif file.endswith(("zip", "rar")): | |
if not os.path.exists("Archives"): | |
os.mkdir("Archives") | |
shutil.move(file, "Archives") | |
archive = archive + 1 | |
print("[", images, "] Images organized Done!") | |
print("[", Code, "] Codes organized Done!") | |
print("[", Docs, "] Docs organized Done!") | |
print("[", archive, "] Archives organized Done!") | |
print("\n") | |
print(" Your files were successfully organized ;)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment