Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Sort Files by Type with Python
New
Rating: 5.0 out of 5(1 rating)
9 students

Sort Files by Type with Python

Automate file organising with Python: paths, loops, file types and a safe dry run to sort any messy folder
Created byThomas McDonald
Last updated 11/2026
English

What you'll learn

  • Write a Python script that automatically sorts a messy folder into subfolders by file type
  • Use Python's os and shutil modules to list, create and move files safely
  • Use loops, if statements and dictionaries to group files by their extension
  • Build a reusable file organiser you can point at any folder, like Downloads, to keep it tidy

Course content

4 sections • 10 lectures • 36m total length
  • Introduction1:36

    See the finished project: a Python script that sorts a messy folder into tidy subfolders by file type. This is a beginner Python automation project, and you'll see what you'll be able to do by the end.

  • Question 1
  • Installing Python2:55

    Download and install Python 3 on Windows, check it works, and run your first line of code. It's a simple, step-by-step Python setup for complete beginners.

  • Question 2

Requirements

  • No programming experience needed. You'll learn every line of Python step by step
  • A Windows, Mac or Linux computer with Python 3 installed (we install it together in the course on Windows)

Description

Is your Downloads or Desktop folder a mess of photos, PDFs, documents and zip files? In this short, hands-on course you'll write a Python script that sorts it all for you, putting every file into a tidy folder for its type, automatically.

This is a beginner Python automation project. You don't need any programming experience. We start by installing Python, then build the script one small step at a time, so you understand every line rather than copying code you can't follow.

What you'll learn:

  • How file paths work, and how to point Python at the right folder without the usual backslash mistakes

  • How a for loop goes through every file in a folder

  • How to read each file's extension (.jpg, .pdf, .txt) and turn it into a folder name, including files with no extension

  • How to run a safe dry run that shows where every file would go before anything moves

  • How to add a simple yes check so nothing moves until you confirm it

  • How to create folders and move files with Python's pathlib module

By the end you'll have a working file organiser you can reuse on any folder, and a real Python project you built yourself.

The course comes with a downloadable workbook for every lecture. It has the key ideas, the exact code, a try-it task, a cheat sheet with the final script, and a troubleshooting page for common errors.

If you want a quick, practical first step into Python that solves a real everyday problem, this course is for you.

Who this course is for:

  • Complete beginners who want a quick first Python project that solves a real problem
  • Anyone with a messy Downloads or Desktop folder who wants to tidy it automatically
  • Office workers and freelancers who want to automate boring file admin
  • Python learners who know the basics and want hands-on practice with files and folders