Moving and Deleting Files and Folders (Review Exercises)
00:00 Time for some review exercises. These are meant for you to practice the methods and attributes and concepts that you learned about in this course. So go ahead and do this by yourself on your computer.
00:11
Create a new directory in your home folder, and call it my_folder/
.
00:17
Inside my_folder/
, create three files, file1.txt
, file2.txt
, and image1.png
. Then move the file image1.png
to a new directory called images/
inside of the my_folder/
directory. Delete the file called file1.txt
, and then also delete the my_folder/
directory. Of course, do all of this using Python’s pathlib
module, right?
00:42
I don’t want you to use your operating system’s graphical user interface to do all that, but instead you should do it using Python’s pathlib
module to practice all the things that you learned about in this course.
00:54
Going over exercises like this a couple of times really helps you to solidify the learning that you take away from this course and makes you get more acquainted and more familiar with the methods in the pathlib
module and with working with files and folders in Python.
Become a Member to join the conversation.
mikepalermo88 on Nov. 4, 2023
Sometimes when I want to move folders I recieve the following error:
Last time it happened I ran CMD as admin and installed
pathlib
andshutil
, then restarted IDLE as admin and it worked. Next time I tried to usepath.replace
(in the same admin IDLE instance), it happened again.Any ideas here?