Moving All Image Files to a New Directory (Challenge)
00:00 If you made it all the way through the review exercises, then I’ve got a challenge for you. I want you to use Python to move all image files into a new directory.
00:09
And start with a file and folder structure that you can download under Supporting Material from this course. There’ll be a ZIP file that you can unzip, and you will find a folder structure in there. There is a folder called practice_files/
and then a subfolder called documents/
. Inside of that directory, there are several files and subfolders.
00:27
Some of the files are images that end with .png
, .gif
, or .jpg
file extensions.
00:35
Now what I want you to do is create a new folder in the practice_files/
folder and call it images/
. And then you want to move all the image files to that folder.
00:44
That means all of the .png
, all the .gif
, and all the .jpg
files, but none others. So when you’re done, the new folder should have four files in it.
00:52
That’s going to be image1.png
, image2.gif
, image3.png
, and image4.jpg
. So, take on this challenge, try to practice using pathlib
some more, and build this little script that you can actually use to move image files from one location to another one.
01:11
And also create the images/
directory using Python’s pathlib
. Just do everything with Python, basically. That’s the challenge for you to give you a nice little capstone for this course.
Martin Breuss RP Team on Jan. 5, 2023
Thanks for flagging this @akazmierz. We’ll update the download later today so that you also get the folder structure together with the code files in the same ZIP file!
Francisco Martínez B on Sept. 6, 2023
Thanks, nice ex.
Become a Member to join the conversation.
akazimierz on Jan. 5, 2023
I got a problem: couldn’t find the zip archive with folders structure and files for the challenge – I checked this lesson (only archives with slides and code), checked at the very beginning of the course, and the end as well (I hope I didn’t make a mistake looking for the archive – if I did, please let me know.)