1
00:00:00,390 --> 00:00:09,120
In this video, I'm showing you my solution for renaming all these ticks was from a dog taxi, for example,

2
00:00:09,300 --> 00:00:14,310
to 2021 Dash dissembled Dash eight, the taxi.

3
00:00:14,520 --> 00:00:15,720
So this is a solution.

4
00:00:15,720 --> 00:00:17,550
And so let me explain what this does.

5
00:00:17,730 --> 00:00:24,050
We import path the path glass because we needed to create path object instances as we do here.

6
00:00:24,060 --> 00:00:31,050
We created the root directory of files, which contains all the folders and files will be operating

7
00:00:31,320 --> 00:00:31,680
on.

8
00:00:31,890 --> 00:00:37,050
And then we iterate for path in that root directory here.

9
00:00:37,080 --> 00:00:45,450
So that is a pattern that allows us to dig inside folders and also subfolders for files for everything.

10
00:00:45,870 --> 00:00:48,570
It's also known as a WOAK operation.

11
00:00:48,570 --> 00:00:50,490
We walk through folders and files.

12
00:00:51,210 --> 00:00:53,550
We check if the item is a file.

13
00:00:54,210 --> 00:01:05,760
If it is a file, then we get the parts and then from parts, we get a section, a slice of those folders.

14
00:01:06,000 --> 00:01:16,470
So a let me comment this out for now and just show you what power and folder is and also what subfolders

15
00:01:16,830 --> 00:01:18,660
are print?

16
00:01:19,710 --> 00:01:26,950
And Sue, the parent folder for the first iteration is this one in here, actually?

17
00:01:26,970 --> 00:01:28,410
Let's see patent folders.

18
00:01:28,980 --> 00:01:37,050
Or you could argue with me and say that this would be named, so I'm going to right click here and go

19
00:01:37,050 --> 00:01:40,560
to change all occurrences and maybe see here.

20
00:01:41,590 --> 00:01:48,660
Passports, rights, and that will change all the same variables in the script.

21
00:01:49,170 --> 00:01:51,000
So that makes more sense.

22
00:01:51,810 --> 00:02:01,380
So passports are these and these extracts from this item to the lost item, including the lost item.

23
00:02:01,530 --> 00:02:05,310
So this has an index of zero, which has an index of one.

24
00:02:05,580 --> 00:02:10,440
So we get that onto here that has an index of minus one.

25
00:02:10,860 --> 00:02:17,250
So that basically gives us this slice of that table, right?

26
00:02:17,700 --> 00:02:18,750
I hope that is clear.

27
00:02:22,890 --> 00:02:29,460
Then what we do is we construct a new file name, which I'm going to expand like this, so that's one

28
00:02:29,460 --> 00:02:29,850
line.

29
00:02:29,880 --> 00:02:34,500
The new file name is this join methods.

30
00:02:34,950 --> 00:02:47,460
What's join does is this if you have a list or a tipple, let's say you have a triple of 2021 and November.

31
00:02:48,540 --> 00:02:56,760
So two items and if you inference apply a string, let's join in parentheses.

32
00:02:56,970 --> 00:02:58,770
So join a string methods.

33
00:02:59,070 --> 00:03:04,450
It will join all this items and it will place this separator between them.

34
00:03:04,800 --> 00:03:07,260
So you get this string.

35
00:03:07,860 --> 00:03:12,030
So the first item, the dash, the second item, and that's it.

36
00:03:12,570 --> 00:03:14,160
So we have the new file name.

37
00:03:15,000 --> 00:03:23,580
So that's one is that one writes 2021 National vember and then we add another dash somewhere in here.

38
00:03:23,970 --> 00:03:29,850
And then after that, we add path dots, a name, the actual name of the file.

39
00:03:30,120 --> 00:03:37,290
So we end up with 20 21 Dash November Dash ABC Dot 16, right?

40
00:03:37,890 --> 00:03:41,490
And then we create a new file path out of that's a new file name.

41
00:03:42,920 --> 00:03:49,850
Using the existing path, using the with new methods, and then we rename the path using that new file

42
00:03:49,850 --> 00:03:50,150
path.

43
00:03:50,570 --> 00:03:51,170
And that's it.

44
00:03:51,710 --> 00:03:53,720
So if I run the script?

45
00:03:55,080 --> 00:04:00,990
This is the arts puts all the files have been renamed to 2021 here.

46
00:04:00,990 --> 00:04:02,310
Twenty twenty two here.

47
00:04:02,750 --> 00:04:04,990
December, December, November and so on.

48
00:04:05,010 --> 00:04:06,360
Everything looks good.

49
00:04:07,140 --> 00:04:07,620
Thank you.

50
00:04:07,650 --> 00:04:08,580
I'll talk to you later.

