Python Basics: File System Operations

Martin Breuss
Martin Breuss 33 Lessons 1h 45m basics python

So far, you’ve written programs that get their input from one of two sources: the user or the program itself. Program output has been limited to displaying some text in IDLE’s interactive window.

These input and output strategies aren’t useful in several common scenarios, such as when:

  • The input values are unknown while writing the program.
  • The program requires more data than a user can be expected to type in by themselves.
  • Output must be shared with others after the program runs.

This is where files come in. You’ve likely been working with computer files for a long time. Even so, there are some things that programmers need to know about files that general users do not. Specifically, you’ll want to master some file system operations using the pathlib and shutil modules.

In this video course, you’ll learn how to:

  • Create files and directories
  • Iterate over the contents of a directory
  • Search for files and folders using wildcards
  • Move and delete files and folders

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3. You can also check out the other Python Basics courses.

Note that you’ll be using IDLE to interact with Python throughout this course. If you’re just getting started, then you might want to check out Python Basics: Setting Up Python before diving into this course.

What’s Included:

Downloadable Resources:

Related Learning Paths:

About Martin Breuss

Martin is Real Python's Head of Content Strategy. With a background in education, he worked as a coding mentor, code reviewer, curriculum developer, bootcamp instructor, and instructional designer.

» More about Martin

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

Avatar image for Dong ZHAO

Dong ZHAO on May 30, 2025

This course helped me a lot on the pathlib module. It carefully explains how to create, delete, and move files and folders/directories.

← Browse All Courses