From the course: Using Python for Automation
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Organize directories with Python - Python Tutorial
From the course: Using Python for Automation
Organize directories with Python
- Ready to get your files in tip-top shape? Python can be so handy to sort and streamline your files and directories. In this lesson, you'll explore how to use Python to organize file directories. Now head to your exercise files, and check out the organize_me folder in your file system. Your goal is to create a program that generates new directories for each file type and organizes this directory. Next, open the organize_me folder in VS Code, and go to organize_starter_code.py. At the top, the first import statement imports the OS library, which contains functions for interacting with your operating system. Then the second import statement imports the path function from the pathlib library. Next, a dictionary named subdirectories is defined. It maps four basic categories: documents, audios, videos, and images, two lists of specific file types. Then a function named organizeDirectory is defined. This takes in a value that represents a file suffix it can encounter, and returns a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Read files with Python3m 12s
-
(Locked)
Write files with Python2m 49s
-
(Locked)
Use Python's command-line interface2m 19s
-
(Locked)
Organize directories with Python3m 19s
-
(Locked)
Parse data with Python6m 9s
-
(Locked)
Extract data with regular expressions2m 51s
-
(Locked)
Validate inputs with automation2m 59s
-
(Locked)
Prepare for error handling2m 43s
-
(Locked)
Automate error handling3m 57s
-
(Locked)
-
-
-
-