Considering Next Steps
I quite like the functionality of this image mover, and I want to be able to use it not just in the
python-basics-exercises/ directory with the
practice_files subdirectory, but instead I want to be able to use it on any folder on my system, let’s say. The functionality is nice.
It creates a new
images/ folder and just moves recursively all the images in there. So I might want to use this somewhere else. And by putting the whole path into this one variable up here, I’m kind of keeping it contained. And for me at least, it makes it easier to think how I would touch the script again to change it.
And I might want to use the
argparse library to collect user input using the command line, and instead of defining the path right here inside of the script, I would allow the user to give the input from the command line. So I would then just need to replace this
FULL_PATH variable here with some code to collect it from the command line. And similarly, I could do the same with the image extensions.
01:30 So maybe the user can define also from the command line which image files they want to move. So having these two pieces of information, the path and the types of extensions that I want to move towards the top of script makes it more accessible and maybe easier to build forward, to build on top of, and keep it general. That’s my reasoning for doing this.
01:53 And I think the script looks great. The code is relatively short. It is quite descriptive. Yeah, it moves towards generalization as well. And you also added a script docstring at the top of the script that describes what this script does.
The honors of pressing F5 for the last time. You see that we get a restart over here in my cleaned-up Python Shell, and I can move over to my folder structure, take a look, and here’s the
images/ folder, and it’s filled up with all the images.
02:39 Perfect. The script works. So this is what I came up with. I’m curious to see what is the code that you wrote. If it’s different, remember that doesn’t have to be wrong. Post it in the comments below, and I’m looking forward to see what you came up with.
Become a Member to join the conversation.