1 00:00:00,560 --> 00:00:03,470 Biton directory and file management. 2 00:00:05,220 --> 00:00:12,630 Is there a large number of files to handle in your Python program, we can arrange our code within different 3 00:00:12,630 --> 00:00:17,280 directories to make things more manageable and reachable. 4 00:00:17,850 --> 00:00:24,590 A directory or folder is a collection of our set of files and sub directory. 5 00:00:24,600 --> 00:00:29,730 So we know that whenever we are having multiple files to handle in some python applications, we can 6 00:00:29,730 --> 00:00:35,440 divide those files in the multiple directories according to the files or the purpose of the file. 7 00:00:35,820 --> 00:00:42,420 And we know that the directory is nothing but one file system which can hold other files or subdirectories. 8 00:00:42,840 --> 00:00:49,940 Python has that with module, which provides us with many useful methods to work with the directories 9 00:00:50,190 --> 00:00:51,850 and the files as well. 10 00:00:51,870 --> 00:00:58,350 So that is one module with so we are suppose to write here import with at the beginning of the code 11 00:00:58,440 --> 00:01:00,360 and then we can go for Westcourt. 12 00:01:00,540 --> 00:01:02,910 Different methods defined in the respective model. 13 00:01:03,540 --> 00:01:10,410 So directory management in Python means creating a directory, renaming it, listing all the directories 14 00:01:10,410 --> 00:01:12,170 and working with them. 15 00:01:12,330 --> 00:01:18,540 So creating a directory, listing a directory, maybe removing a directory, renaming a directory can 16 00:01:18,540 --> 00:01:22,540 be done using this directory management library functions. 17 00:01:22,770 --> 00:01:28,590 So let us go for one demonstration, for the easy understanding to show you that how this file and directory 18 00:01:28,590 --> 00:01:36,090 management can be done in our Python applications to do some operations on the file and directories 19 00:01:36,090 --> 00:01:38,250 were importing the model that is OS. 20 00:01:38,580 --> 00:01:46,680 So we operate in import ways at the method we are going to initiate to execute is Getsy W.D. There is 21 00:01:46,680 --> 00:01:53,670 a current working directory, so it returns the present working directly in which we are now existing. 22 00:01:54,090 --> 00:01:55,260 And then we print. 23 00:01:55,500 --> 00:02:02,760 We get current working directory in the bite that will return the present working directory as a bright 24 00:02:02,760 --> 00:02:03,370 object. 25 00:02:03,720 --> 00:02:05,190 So let us go for the execution. 26 00:02:05,200 --> 00:02:05,930 You can see that. 27 00:02:06,390 --> 00:02:10,680 So at first it is telling that we are existing in this particular current directory. 28 00:02:10,680 --> 00:02:14,350 So are in this particular directory that is scicluna users or not. 29 00:02:15,000 --> 00:02:23,220 And now if I want to execute this method, there is a getsy w DBI, then it is showing me that it is 30 00:02:23,220 --> 00:02:28,290 the current working directory and it is it will be returned as a bright object. 31 00:02:28,980 --> 00:02:32,750 So now let us go for one change directory here. 32 00:02:33,120 --> 00:02:37,740 So here you see we are actually in this particular current directory that is user Arnab. 33 00:02:38,190 --> 00:02:42,630 Now from this we are trying to go to the directory that is a file test. 34 00:02:42,930 --> 00:02:45,130 So our part will be something like this. 35 00:02:45,450 --> 00:02:48,350 So now let let us go for the execution here. 36 00:02:48,570 --> 00:02:51,660 So Scallan users or no file test. 37 00:02:52,020 --> 00:02:53,700 So that is a change directory. 38 00:02:53,700 --> 00:02:58,560 The method is desired, which will be used to change the current directory. 39 00:02:58,830 --> 00:03:04,120 And we are going to insert we're going to go into this file folder. 40 00:03:04,470 --> 00:03:10,110 So now if I go for this and then we are going for this list directory that was all files and subdirectories 41 00:03:10,110 --> 00:03:14,330 inside a directory can be known using the least darte method. 42 00:03:14,490 --> 00:03:15,720 So we are executing this. 43 00:03:16,290 --> 00:03:21,330 So you see we are getting this list of files or three files on Banda's and one test. 44 00:03:22,290 --> 00:03:23,460 So let us check. 45 00:03:23,760 --> 00:03:26,490 Yes, we are having three files on Ponder's and then one day. 46 00:03:27,810 --> 00:03:31,720 So to get this list, we are using this method that is a list dark. 47 00:03:32,410 --> 00:03:35,700 OK, so we have gone for this particular folder. 48 00:03:35,710 --> 00:03:36,990 We are now in this particular folder. 49 00:03:37,020 --> 00:03:43,110 So now if I bring this one, it will bring that in which folder we are actually belonging at this moment. 50 00:03:45,050 --> 00:03:53,180 So if we can find out where in this particular folder right at this moment, OK, no, we shall make 51 00:03:53,180 --> 00:03:55,000 a new directory, there is a test. 52 00:03:55,400 --> 00:04:02,500 So the method is Makatea that is directly used to make a new directory under the present directory. 53 00:04:02,780 --> 00:04:04,900 So the test will be will be created. 54 00:04:04,910 --> 00:04:08,480 So you see there is no existence of any test folder here. 55 00:04:09,020 --> 00:04:11,240 So let us go for execution of the same. 56 00:04:11,960 --> 00:04:17,240 So we are supposed to get one test folder and the folder is empty, but the folder has got created. 57 00:04:18,080 --> 00:04:21,440 Next, we are going for used to rename a directory. 58 00:04:21,470 --> 00:04:28,580 So now we are going to use the method that is rhenium, which will rename this folder to this new one. 59 00:04:28,790 --> 00:04:29,510 New one. 60 00:04:29,510 --> 00:04:31,580 There is another filename we are going to give. 61 00:04:31,850 --> 00:04:33,530 So now let us go for the execution. 62 00:04:34,010 --> 00:04:39,350 Are you going to find that the test folder has got renamed to the new one here and the folder is empty? 63 00:04:41,290 --> 00:04:46,790 OK, now removing a file and a directory, so how to remove a file and how to remove one directory. 64 00:04:47,110 --> 00:04:50,760 So here you are removing desk and new one folder. 65 00:04:51,070 --> 00:04:53,410 So the respective methods are removed. 66 00:04:53,430 --> 00:04:59,530 Remove will be used to remove one file and our immediate method will be used to remove our directory 67 00:04:59,530 --> 00:04:59,790 here. 68 00:05:00,070 --> 00:05:01,910 So let us go for the execution of the same. 69 00:05:02,170 --> 00:05:03,640 So we have executed this one. 70 00:05:03,650 --> 00:05:05,710 So test got a new one. 71 00:05:06,220 --> 00:05:12,900 You can find that they are not existing at this moment because we have executed these two calls. 72 00:05:13,150 --> 00:05:16,350 So now we again, we are going to change to our directory. 73 00:05:16,360 --> 00:05:20,840 There is a pen and one we went under this particular file desk when you were coming out. 74 00:05:21,040 --> 00:05:25,510 So again, we are using the method that is associated desired. 75 00:05:25,780 --> 00:05:30,950 So again, we shall come back to my Atami Scallon users or no folder. 76 00:05:31,330 --> 00:05:37,180 So in this particular demonstration, we have shown you that how to operate with the file, how to delete 77 00:05:37,180 --> 00:05:43,600 it, and how to rename one folder, how to create one folder and so on, and how to see that in which 78 00:05:43,750 --> 00:05:50,680 current working directory directly where belonging and other different issues in the proper demonstration. 79 00:05:50,800 --> 00:05:55,510 And you see right at this moment, we are not having any folder here, not a test. 80 00:05:56,410 --> 00:05:59,030 So they have got removed and they have got deleted. 81 00:05:59,650 --> 00:06:00,940 Thanks for watching this video.