1
00:00:00,120 --> 00:00:06,630
Here on my programming environment, I have these files directory, which has these three files.

2
00:00:07,380 --> 00:00:16,140
Each of them has this unwanted comma of the end, and I want to remove that comma from every file via

3
00:00:16,140 --> 00:00:23,500
Python formats that I'm going to iterate over these files and to iterate over these files.

4
00:00:23,520 --> 00:00:28,620
First, we need a list of these file paths to create a list.

5
00:00:28,650 --> 00:00:34,530
It's good to use from past leap import path solver path class.

6
00:00:35,220 --> 00:00:42,810
And as you may know from the previous videos with file operations first, when we import path, we want

7
00:00:42,810 --> 00:00:47,160
to create a file directory or something like that.

8
00:00:47,820 --> 00:00:50,790
So which is equal to path files?

9
00:00:51,570 --> 00:01:00,420
Files is the name of the folder so that we create, as you can see, files easier as.

10
00:01:01,560 --> 00:01:11,580
A path object type that points to the fires folder, and we can make use of that by iterating for file

11
00:01:11,580 --> 00:01:17,200
path and file their dots ITR dear.

12
00:01:17,910 --> 00:01:24,810
And you'll see that file path as each of the paths or these files.

13
00:01:25,980 --> 00:01:34,230
So we have access to the file paths, then we can go ahead and open all these files.

14
00:01:34,230 --> 00:01:43,710
Births so far path in open as an read mode as a file.

15
00:01:44,730 --> 00:01:46,860
So file is the file object.

16
00:01:46,980 --> 00:01:49,550
Don't confuse file with file path.

17
00:01:49,560 --> 00:01:54,570
File path is the path to that file object in that file object.

18
00:01:55,740 --> 00:02:01,650
We apply file that is read and stored that stream in a contents variable.

19
00:02:02,250 --> 00:02:04,410
Then we modify that content.

20
00:02:07,080 --> 00:02:13,260
So we saw in a new variable the texts accept the lost character.

21
00:02:14,460 --> 00:02:19,200
So with that slice, you know, from the previous video that said, we extract all the characters,

22
00:02:19,200 --> 00:02:20,220
but the lost one.

23
00:02:20,460 --> 00:02:29,430
Then what we do with this new string is we open a new file path.

24
00:02:29,460 --> 00:02:33,540
So if you want to override the existing files, you want to do that.

25
00:02:34,770 --> 00:02:42,900
So you want to use the same file path, which means you will override the existing files with the new

26
00:02:42,900 --> 00:02:48,270
files that you open in rides modes here as file again file.

27
00:02:48,270 --> 00:02:56,310
That's roids new content, but I would like to make a copy of this folder to back it up.

28
00:02:57,180 --> 00:03:04,440
Now in Europe, I don't have an option to make a copy of this folder if you were locally in your computer.

29
00:03:04,680 --> 00:03:08,340
You can just copy that folder and paste it in another name.

30
00:03:08,880 --> 00:03:17,190
If you are on Ripple, you want to go to the shell and first make a new directory where to put the new

31
00:03:17,190 --> 00:03:23,340
files or add Kadir files back up.

32
00:03:24,720 --> 00:03:26,660
That gives you a new empty directory.

33
00:03:26,670 --> 00:03:28,800
Then you want to copy S..

34
00:03:30,970 --> 00:03:41,400
That's a to preserve file attributes and then files Slashdot and files back up.

35
00:03:42,910 --> 00:03:44,680
There's a complete command set around that.

36
00:03:45,220 --> 00:03:53,710
And now you should see all the original files inside the Files backup folder, so let's carry on with

37
00:03:53,710 --> 00:03:54,160
the codes.

38
00:03:54,670 --> 00:03:58,480
Now I can run these codes without losing the original files.

39
00:03:59,260 --> 00:04:04,720
So run and let's check file for common file five.

40
00:04:04,720 --> 00:04:07,750
No comma file six no comma of the ends.

41
00:04:08,080 --> 00:04:09,910
So that is the complete code.

42
00:04:11,500 --> 00:04:17,410
In the next video, we will replace a word with another word from all the files.

43
00:04:17,950 --> 00:04:19,360
I'll talk to you in the next video.

