1
00:00:00,360 --> 00:00:05,370
In this lecture, you learn how to extract the zip files.

2
00:00:05,760 --> 00:00:09,090
So in this directory here, I have two zip files.

3
00:00:09,660 --> 00:00:17,010
Items, 1.60 and items to each of them have some Sears files inside.

4
00:00:17,460 --> 00:00:27,180
Now the purpose of the scripts that we're going to write is to put each of these file sets into two

5
00:00:27,180 --> 00:00:32,070
different folders inside the destination folder, which is currently empty.

6
00:00:32,729 --> 00:00:39,300
So by the end of this video, we're going to have two folders items one and items two, and each of

7
00:00:39,300 --> 00:00:44,160
those folders will have the corresponding files from each of these zip files.

8
00:00:53,200 --> 00:01:01,570
So we need the path object and the Zip File Library also routes dear, this time is going to be path.

9
00:01:02,170 --> 00:01:04,780
So guess what is the root directory?

10
00:01:04,840 --> 00:01:07,110
Where are we working on?

11
00:01:07,120 --> 00:01:17,890
I think is the project directory, which is that so adult means it's in the same directory as the script,

12
00:01:18,280 --> 00:01:21,610
the script main that spy is here in this factory.

13
00:01:22,060 --> 00:01:24,880
So that means we're working in the same directory.

14
00:01:25,510 --> 00:01:33,460
But let's also define the destination directory or path, whatever you'd like to call it.

15
00:01:33,940 --> 00:01:39,580
So this would be a path object also that points to this destination folder.

16
00:01:41,650 --> 00:01:52,060
And then you say for path in deer that are gallop or should we use Glob this time?

17
00:01:52,750 --> 00:02:01,510
So our globe would go inside each of the folders, but if you just want to check one level, so if you

18
00:02:01,570 --> 00:02:05,470
want to check this directory only, then you want to use Galop.

19
00:02:07,210 --> 00:02:15,490
Not our globe, because our global check subfolders also so that zip we iterate to get access to these

20
00:02:15,490 --> 00:02:22,030
files and we open each file using zip file that zip file.

21
00:02:22,780 --> 00:02:28,280
So path that's one this time should be a read mode.

22
00:02:28,300 --> 00:02:31,120
We are not modifying these files.

23
00:02:31,330 --> 00:02:34,780
We're just reading them and seeing what they have inside.

24
00:02:35,050 --> 00:02:40,220
So that's a reads operation as that's f that f is just so valuable.

25
00:02:40,720 --> 00:02:48,790
And no, we would say that I have that extract all that the methods to extract the files.

26
00:02:49,750 --> 00:02:52,240
And this gets us past arguments.

27
00:02:52,240 --> 00:02:53,380
You see path here.

28
00:02:53,890 --> 00:03:00,880
It's an argument of this and the path is equal to perhaps the destination path.

29
00:03:01,300 --> 00:03:06,370
So basically, this should be a directory path, not a file path.

30
00:03:07,120 --> 00:03:12,070
This is a destination directory where the files should be extracted.

31
00:03:12,550 --> 00:03:18,640
And if we leave it like that, all the files will be extracted inside this nation.

32
00:03:19,000 --> 00:03:27,220
But if you want to have separate folders for each of these instead of putting them all in one folder,

33
00:03:27,490 --> 00:03:30,200
then you want to create a new path.

34
00:03:30,220 --> 00:03:40,510
Let's say final path is equal to destination path slash another path, which I would say could be something

35
00:03:40,510 --> 00:03:42,640
like path the system.

36
00:03:43,090 --> 00:03:49,060
So that's path is this item swan the zip.

37
00:03:49,330 --> 00:03:52,510
Then it's items to the zip and paths.

38
00:03:52,510 --> 00:03:58,690
TAM gets only that first part without the extension, without the DOT.

39
00:03:59,260 --> 00:04:01,960
So it gets only items one as a string.

40
00:04:02,140 --> 00:04:03,760
So this is a string, actually.

41
00:04:04,270 --> 00:04:08,080
So we construct a path using the destination path.

42
00:04:08,080 --> 00:04:15,760
So of the product of this will be destination slash items one in the first iteration.

43
00:04:15,910 --> 00:04:26,260
You can check that if you stop the scripts here, use this point and then go to debugger and press that

44
00:04:26,350 --> 00:04:27,100
run button.

45
00:04:30,090 --> 00:04:33,960
So you see, no, that path is here.

46
00:04:36,700 --> 00:04:40,450
And 10 is currently items rights.

47
00:04:42,330 --> 00:04:43,890
In that current situation.

48
00:04:45,040 --> 00:04:50,770
So we're using the debugger to stop the execution of the script of the line where I place the dot,

49
00:04:51,370 --> 00:04:52,540
so stop that.

50
00:04:53,320 --> 00:04:55,930
And yeah, that should do it, I think.

51
00:04:55,930 --> 00:05:01,470
But here now with Path, Path is equal to final path.

52
00:05:03,580 --> 00:05:03,790
Yeah.

53
00:05:04,090 --> 00:05:04,660
And run.

54
00:05:06,720 --> 00:05:08,400
See the destination.

55
00:05:08,640 --> 00:05:11,550
Yeah, so we have these two directories, items one.

56
00:05:12,270 --> 00:05:17,250
These are the files that were inside item one, the zip and items too.

57
00:05:17,940 --> 00:05:20,610
These are the files that were inside items to the zip.

58
00:05:21,150 --> 00:05:22,350
And as a final code.

59
00:05:22,410 --> 00:05:25,410
Let me delete that breakpoint.

60
00:05:25,410 --> 00:05:28,350
And so I hope to see you in the next videos to.

