Organize file using python within few milliseconds

 Organize file using python within few milliseconds




Step 1: Create a new python file

Step 2: Paste the below code.
    
import os
import shutil

# declare file formate here and add extension to file formate
image_formats = ["jpg","png","gif","webp","jpeg"]
audio_formats = ["mp3","wav"]
video_formats = ["mp4","avi","web"]
docs_formats = ["ai","ait","txt","rtf","pdf"]

while True:
	files = os.listdir("./")
	for file in files:
		if os.path.isfile(file) and file != "fileOrganiser.py":
			ext = (file.split(".")[-1]).lower()
			if ext in image_formats:
				shutil.move(file,"images/"+file)
			elif ext in audio_formats:
				shutil.move(file,"audio/"+file)
			elif ext in video_formats:
				shutil.move(file,"video/"+file)
			elif ext in docs_formats:
				shutil.move(file,"docs/"+file)
			else :
				shutil.move(file,"other/"+file)

Step 3: Run the program and see magic.

Post a Comment

0 Comments