1
00:00:00,060 --> 00:00:06,780
Let's suppose you want to sell your computer and therefore you delete all your files.

2
00:00:07,110 --> 00:00:13,110
But however, that's not completely safe because there are ways to recover those files.

3
00:00:13,860 --> 00:00:19,230
But in this video, we will write a script to have Python destroy those files.

4
00:00:20,190 --> 00:00:28,500
The technique we will use is by changing the contents of those files first and then delete them with

5
00:00:28,500 --> 00:00:29,040
Python.

6
00:00:29,460 --> 00:00:31,170
So this is how we're going to do this.

7
00:00:31,590 --> 00:00:33,720
We use the path object as usual.

8
00:00:33,900 --> 00:00:40,200
This is a route directly where the files you want to delete are located destination.

9
00:00:40,200 --> 00:00:44,850
In our case, which has these three Series B files.

10
00:00:45,720 --> 00:00:50,130
This one, that's and that's each of them has some content inside.

11
00:00:50,970 --> 00:00:59,310
So you want to iterate over routes there with Galop, you have to be careful here.

12
00:00:59,880 --> 00:01:03,630
So don't use our globe if you're not sure what you're doing.

13
00:01:04,680 --> 00:01:11,910
Because our globe will also go through subfolders, so you don't want to change files that you don't

14
00:01:11,910 --> 00:01:18,270
want to change, so see as we we want to get all the CSB files.

15
00:01:18,600 --> 00:01:23,880
So the extension could also be important here because you specify that you want to work on the see as

16
00:01:23,880 --> 00:01:24,330
we file.

17
00:01:25,350 --> 00:01:33,840
And the techniques to change these files is by using the open function, which gets as a part of each

18
00:01:33,840 --> 00:01:38,070
file of the root directory and opens.

19
00:01:38,070 --> 00:01:40,980
It's in W. B mode.

20
00:01:41,820 --> 00:01:47,040
WB means rides, writes modes and B means binary.

21
00:01:47,220 --> 00:01:52,830
So this method works also for binary files, but also for text files.

22
00:01:53,400 --> 00:02:01,020
So we go here and we see as file and file right now we want to write.

23
00:02:02,500 --> 00:02:09,940
A Boyds objects, which goes like this B and then includes you enter the so-called bytes.

24
00:02:11,020 --> 00:02:15,670
And I'm going to leave this empty, so just an empty binary file.

25
00:02:15,700 --> 00:02:17,590
And yeah, that's it.

26
00:02:18,310 --> 00:02:19,630
Now if I were on this.

27
00:02:20,940 --> 00:02:22,650
OK, I forgot that in here.

28
00:02:22,800 --> 00:02:24,150
So let's run again.

29
00:02:25,230 --> 00:02:27,720
The execution finished, apparently.

30
00:02:28,140 --> 00:02:32,400
And if you open all these files, these are empty.

31
00:02:32,610 --> 00:02:39,900
Before we had that content, one content to etc. So we had some content and now we have not the same

32
00:02:39,900 --> 00:02:40,260
files.

33
00:02:41,310 --> 00:02:43,050
And of course, this is not enough.

34
00:02:43,080 --> 00:02:48,330
So we also want to delete the file using the unlink methods.

35
00:02:49,170 --> 00:02:54,950
So after that, with context manager ends, you see, this is unintended.

36
00:02:54,960 --> 00:02:57,510
It's not part of the wave context manager.

37
00:02:57,870 --> 00:02:59,370
You want to delete that.

38
00:02:59,670 --> 00:03:05,520
For example, let's add one more time some content there and to run the script.

39
00:03:06,390 --> 00:03:06,660
Yeah.

40
00:03:06,810 --> 00:03:11,640
So the files are first changed and then deleted.

41
00:03:12,120 --> 00:03:13,680
So that's the complete script.

42
00:03:13,950 --> 00:03:14,460
Thank you.

43
00:03:14,550 --> 00:03:15,570
I'll talk to you later.

