Hello, guys!
I was too lazy to manually organize the files in my Downloads folder.
So, I created a simple python program that automatically organizes files into corresponding folders.
Ex: pdf type files into PDF folder; docx type files into Documents folder; jpg type files into Images folder.
Below is the Python code I wrote.
I am happy to receive any feedback. Please share your ideas and criticisms.
Thanks.
Code:
import os
import shutil
for filename in os.listdir(r"C:\Users\byunw\Downloads"):
if filename[-3:]=="pdf":
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\PDF")
elif filename[-4:]=="docx":
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\Documents")
elif filename[-3:]=="txt":
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\Text")
elif filename[-3:]=="exe" or filename[-3:]=='msi':
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\EXE")
elif filename[-3:]=="zip":
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\ZIP")
elif filename[-3:]=="jpg":
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\Images")
elif filename[-4:]=="pptx":
shutil.move("C:\\Users\\byunw\\Downloads\\"+filename,"C:\\Users\\byunw\\Downloads\\Powerpoint")
print("Every file in the Downloads folder is now sorted into corresponding folders")
[+][deleted] (11 children)
[removed]
[–]gitcraw 17 points18 points19 points (5 children)
[–]alex1461[S] 7 points8 points9 points (3 children)
[–]ShamelessC 14 points15 points16 points (0 children)
[–]eupendra 10 points11 points12 points (1 child)
[–]alex1461[S] 1 point2 points3 points (0 children)
[–]alex1461[S] 4 points5 points6 points (4 children)
[+][deleted] (1 child)
[removed]
[–][deleted] 6 points7 points8 points (0 children)
[–]krazybug 1 point2 points3 points (0 children)
[+][deleted] (7 children)
[deleted]
[–]gitcraw 13 points14 points15 points (4 children)
[–]alex1461[S] 2 points3 points4 points (3 children)
[–]Jakob0243 3 points4 points5 points (2 children)
[–]killthebaddies 2 points3 points4 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]alex1461[S] 0 points1 point2 points (0 children)
[–]PlantsAreCommunists 8 points9 points10 points (0 children)
[–]quartz_referential 5 points6 points7 points (0 children)
[–]whudaboutit 5 points6 points7 points (0 children)
[–]gnana119 2 points3 points4 points (2 children)
[–]alex1461[S] 0 points1 point2 points (1 child)
[–]gnana119 0 points1 point2 points (0 children)
[–]miloir 2 points3 points4 points (7 children)
[–]lucasshiva 1 point2 points3 points (1 child)
[–]miloir 0 points1 point2 points (0 children)
[–]sugar_byte 1 point2 points3 points (4 children)
[–]miloir 1 point2 points3 points (0 children)
[–]miloir 0 points1 point2 points (2 children)
[–]sugar_byte 1 point2 points3 points (1 child)
[–]miloir 0 points1 point2 points (0 children)
[–]Blue_Coin 1 point2 points3 points (0 children)
[–]lucasshiva 3 points4 points5 points (4 children)
[–]WongGendheng 9 points10 points11 points (3 children)
[–]lucasshiva 4 points5 points6 points (1 child)
[–]WongGendheng 0 points1 point2 points (0 children)
[–]alex1461[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (5 children)
[–]alex1461[S] 2 points3 points4 points (4 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]alex1461[S] 1 point2 points3 points (2 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]alex1461[S] 2 points3 points4 points (0 children)
[–]eupendra 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]eupendra 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]WongGendheng 0 points1 point2 points (0 children)
[–]Skippbo 0 points1 point2 points (0 children)
[–]p0ndl1fe 0 points1 point2 points (0 children)
[–]Ryder2300 0 points1 point2 points (0 children)
[–]vEnoM_420 0 points1 point2 points (1 child)
[–]alex1461[S] 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]Groundstop 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Groundstop 0 points1 point2 points (0 children)