Now that we know how to write a Python script using a module basically putting all of our code in a Python file, let's just use that same structure to build a script that will traverse the file system, that is it will walk through different directories and files. Python has a very useful module that has utilities that will help us here, these utilities are in the OS module. So let's inquiry over here, and then OS will help us, and we'll write all of the or most of the logic in the main function. Then we'll execute these and then we'll see how these work. Basically what we want do is use the walk helper in OS. The walk helper will give us the main, the root, the directories, and then the files when it's traversing the file system. We're going to do for root, directories, files in OS that walk, and I'm going to use my third files directory over here. Just to get started in to understand what's going on here, we are going to be printing these different these three things as it's traversing that pass. First we're going to print. Let's print the root, and then we will print, let's say this is a root. We can identify what's going on, then we're going to say we're going to print directories, and finally we're going to say the files. Files is going to be like that so what is going on here is that always that walk is going to produce a three groups of items, one is a root, then the directories, and then the files. It's up to us to go through these variables and use them to find what we need to work with. Now before I run these, one thing that you have to be aware of is that if I use the short notation for the path that is abbreviating the path for my home directory with these character, this will not expand. So if I run it, nothing will show is basically the script running, and that won't show. What we want here is to use absolute paths, I'm going to use Users/alfredo/dotfiles, when I say these, and if I run it, you will see that I'm getting several files and directories here that are getting a little bit interesting. Now these might look confusing when I scroll all the way to tab, you can see directories are nothing but there's a lot of files, it's says there root disease, and the more directories. The trick here this might feel very confusing. The trick here is to basically ignore the directories, and if you want to work with files, then loop over the files themselves. Files will always be you can see directories, and place here you have file sees a list with one item if you do that, then the output will be a little bit better do digest. Let's loop over the files. Someone has said, four file in files, then you can do, for example, let's join the file and the root that will give you an absolute path. We can say apps, absolute path is going to be always we're going to use the OS module again, and we're going to use always that path, and we're going to see join the root, and the file. That's will give us the absolute path, and we can say here print the actual files. When I say file path, and we're going to do absolute path here in curly brackets, and then we're going to remove these things so that we can have better output. I'm going to say that, and I hit clear over here so that we can run this again, and get some nice paths over there. Now you can see there we're traversing everything, I'm going to scroll all the way to the tab, these has annoying Albert bit. Now it's going to grab every single path and the root becomes effectively all the way up until the root of that file. In this case well. Let's find an R1 that is a little bit more readable. There is now using the modules but you can see there's a lot of good modules. For example these README that RISD file the root would be everything before that, so /users/alfredo/dotfiles.zsh-plug-ins that will be the root. By joining that way, you can definitely find that. Now if you were to want to process only directories, where you would do something. You'll basically looping over the directory's list that is MapReduce. You would do for directory in directories, and then instead of joining the file you join the directory, and then the file path wouldn't be a file path that it will be directory paths. It'll be there path, and then I say that, and then I run it. Now I will be only getting directories produced, and no longer files. All of these things are directories. You can see here this is full of directories, that then that get all these are directories only. So that is effectively how you create a script that uses the OS module to traverse the file system again very good tip is don't get into trouble by now using absolute paths here that might gauge you into trouble because things will not work, and I've shown you how to work with both directories, and files using the OS module.