By directory and file management.
Is there a large number of files to handle in your Biton 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 you are having multiple files to handle in some python applications, we can
divide those files into multiple directories according to the file size 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 the W model, which provides us with many useful methods to work with the directories and
the files as well.
So that is one model called with.
So we are suppose to write here import ways at the beginning of the code and then we can go for ways
dot 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 reviewing 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 directory is
what importing the model that is?
Oh yes.
So we operate in import with at first of methode.
We are going to initiate and do execute is get C W.D..
There is a current working directory, so it returns the present working directory in which we are now
existing and then we'll print with get current working directory in the bite.
That means returns of prison working directory as a byte 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 ready in this particular Guardian directory that is equal on users or not.
I know if I want to execute this method that is a get C, W, D, B, then it is showing me that it
is the current working directory and it is it will be returned as a byte object.
So now let us go for one change directory here.
So here you see we are actually in this particular calendrical.
That is user or not.
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 sequel on users or no file test.
So that is of a change directory.
That method is C desire, which will be used to change the current directory.
And we are going to insert it.
We we're going to go into this file test folder.
So now if I go for this and then we are going for this list directory, that means all files and subdirectories
inside the directory can be known using the least dard 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 dot text.
So let us check.
Yes, we are having three files on Sundays and then one is dark BSD.
So to get this list, what, 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 I execute, we can find that one in this particular folder right at this moment.
OK.
Now we shall make a new directory that is a test.
So the method is aimed at desire.
That is make directory used to make a new directory under the present directory.
So the test will be will be created.
So you'll see that is.
No.
A distance of any test folder here.
So let s go for execution of the same.
So we are supposed to get one test folder in.
The folder is empty, but the folder has got created.
Next we are going for use to rename a directory.
So now we are going to use the method that is the rhenium which will rename this test folder to this
new one.
New one.
There is another for Lenine we are going to give.
So now let us go for the execution and you can find that the test folder has got the name 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 moving this dark tsd and new one folder.
So the respective methods are remove, remove will be used to remove one file and Artim desired method
will be used to remove our directory here.
So let's go for the execution of the same.
So we have executed this one.
So Tess Dot, DSD, a new one.
You can find that they are not existing at this moment because we have executed these two calls.
So now we going we are going to change two of our directory.
There is a pendant, one we went to under this particular file.
That's not when you are coming out.
So, again, we're using the method that is a C HDR.
So again, we shall come back to my to my siecle on users or no folder.
So in this particular demonstration, we have shown you that how to operate with the file, how to deleted
and how to rename one folder.
How to create one folder and so on.
And how to see that in which got into working directory directly where belonging and other different
issues in the proper demonstration.
And you see right at this woman, we're not having any folder here.
Not that this dot dxp.
So they have got removed and they have got delivered.
Thanks for watching this video.