Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

The Challenge: Moving All Image Files to a New Directory

00:00 So you ready for a challenge? This challenge is to move all image files to a new directory.

00:06 So when you download the code resources under supporting material, then you can find in there a folder that’s called practice_files/, and it has a subfolder that’s called documents/.

00:17 And then the documents/ directory contains several files and subfolders. And some of them are image files. They are going to have the endings .png, .gif, or .jpg.

00:29 Once you’ve downloaded this folder, go ahead and inspect it. Click around in there. It should look something like this. So you have the practice_files/ folder, then a documents/ subfolder, and then there’s a bunch of stuff in there. And among other things, there are image files. For example, here is image3.png, image4.jpg, image2.gif, and image1.png.

00:56 Now your task is to create a new folder in the practice_files/ folder and call it images/. And then you want to move all the image files into that folder.

01:05 So once you’re done, the new folder should have four files in it, the ones that I just mentioned before and that are listed here on the file again. Of course, your challenge is to do all of this with Python’s pathlib module.

01:17 Here’s a couple of tips to take along on your way.

01:21 Just like before, use code comments to help you get organized. Break out the challenges in smaller tasks, then tackle one task at a time. Look up any documentation if you need help.

01:34 You can go to the pathlib documentation or go back to the course. You also want to test repeatedly to see whether your code actually does what you expect it to do. So that could be using pathlib, or you can use your graphical user interface to see whether what you expect to happen actually happens. So those are some tips to take along on the way.

01:54 And now again, I will suggest you to stop here and don’t continue with the course. Try to tackle this challenge yourself. See if you can make it to the end, if you can complete it successfully. If you do need help, try a little before you actually go and look up the lessons.

02:12 But then you can always go to the next lesson and then watch me how I would solve this challenge. And keep in mind that that’s just a different way of doing it.

02:20 If you solved it differently, that is completely fine. There’s always many, many different ways that you can tackle a challenge, and comparing your own approach to someone else’s approach can be a helpful way to learn and train your coding skills. So get started.

02:36 Prepare for the challenge and tackle it. And once you’re done, move on to the next lesson and then watch over me solving the challenge.

Become a Member to join the conversation.