A Python script that scans a folder and automatically sorts files into subfolders by type — images, documents, videos, code files. Great for learning os and shutil modules.
Follow these steps in order. Each one builds on the previous.
Import os and shutil
Define a dictionary mapping extensions to folder names
Loop through files in the target directory
Check each file's extension
Create the destination folder if it doesn't exist
Move the file using shutil.move()
Print a summary of moved files
Loading...