Biton directory and file management.
Is there a large number of files to handle in your Python program, we can arrange our code within different
directories to make things more manageable and reachable.
A directory or folder is a collection of our set of files and sub directory.
So we know that whenever we are having multiple files to handle in some python applications, we can
divide those files in the multiple directories according to the files or the purpose of the file.
And we know that the directory is nothing but one file system which can hold other files or subdirectories.
Python has that with module, which provides us with many useful methods to work with the directories
and the files as well.
So that is one module with so we are suppose to write here import with at the beginning of the code
and then we can go for Westcourt.
Different methods defined in the respective model.
So directory management in Python means creating a directory, renaming it, listing all the directories
and working with them.
So creating a directory, listing a directory, maybe removing a directory, renaming a directory can
be done using this directory management library functions.
So let us go for one demonstration, for the easy understanding to show you that how this file and directory
management can be done in our Python applications to do some operations on the file and directories
were importing the model that is OS.
So we operate in import ways at the method we are going to initiate to execute is Getsy W.D. There is
a current working directory, so it returns the present working directly in which we are now existing.
And then we print.
We get current working directory in the bite that will return the present working directory as a bright
object.
So let us go for the execution.
You can see that.
So at first it is telling that we are existing in this particular current directory.
So are in this particular directory that is scicluna users or not.
And now if I want to execute this method, there is a getsy w DBI, then it is showing me that it is
the current working directory and it is it will be returned as a bright object.
So now let us go for one change directory here.
So here you see we are actually in this particular current directory that is user Arnab.
Now from this we are trying to go to the directory that is a file test.
So our part will be something like this.
So now let let us go for the execution here.
So Scallan users or no file test.
So that is a change directory.
The method is desired, which will be used to change the current directory.
And we are going to insert we're going to go into this file folder.
So now if I go for this and then we are going for this list directory that was all files and subdirectories
inside a directory can be known using the least darte method.
So we are executing this.
So you see we are getting this list of files or three files on Banda's and one test.
So let us check.
Yes, we are having three files on Ponder's and then one day.
So to get this list, we are using this method that is a list dark.
OK, so we have gone for this particular folder.
We are now in this particular folder.
So now if I bring this one, it will bring that in which folder we are actually belonging at this moment.
So if we can find out where in this particular folder right at this moment, OK, no, we shall make
a new directory, there is a test.
So the method is Makatea that is directly used to make a new directory under the present directory.
So the test will be will be created.
So you see there is no existence of any test folder here.
So let us go for execution of the same.
So we are supposed to get one test folder and the folder is empty, but the folder has got created.
Next, we are going for used to rename a directory.
So now we are going to use the method that is rhenium, which will rename this folder to this new one.
New one.
There is another filename we are going to give.
So now let us go for the execution.
Are you going to find that the test folder has got renamed to the new one here and the folder is empty?
OK, now removing a file and a directory, so how to remove a file and how to remove one directory.
So here you are removing desk and new one folder.
So the respective methods are removed.
Remove will be used to remove one file and our immediate method will be used to remove our directory
here.
So let us go for the execution of the same.
So we have executed this one.
So test got a new one.
You can find that they are not existing at this moment because we have executed these two calls.
So now we again, we are going to change to our directory.
There is a pen and one we went under this particular file desk when you were coming out.
So again, we are using the method that is associated desired.
So again, we shall come back to my Atami Scallon users or no folder.
So in this particular demonstration, we have shown you that how to operate with the file, how to delete
it, and how to rename one folder, how to create one folder and so on, and how to see that in which
current working directory directly where belonging and other different issues in the proper demonstration.
And you see right at this moment, we are not having any folder here, not a test.
So they have got removed and they have got deleted.
Thanks for watching this video.