1
00:00:00,090 --> 00:00:07,950
In this video, I'll teach you how to get the deed when a file was created via Python.

2
00:00:08,070 --> 00:00:10,370
And I'll also give you an exercise.

3
00:00:10,380 --> 00:00:19,350
You can practice this tool by renaming all these files, adding the dates when the file was created

4
00:00:19,350 --> 00:00:21,150
to each of these file names.

5
00:00:21,690 --> 00:00:23,310
And so the output.

6
00:00:24,570 --> 00:00:27,540
All this exercise would be something like this.

7
00:00:27,720 --> 00:00:38,430
You see that a text has been renamed to the date time on the score a 30.

8
00:00:39,630 --> 00:00:48,810
Same for the next file 20, 21, 11, zero to underscore date and so on.

9
00:00:49,140 --> 00:00:51,390
So we have the year and we have the month.

10
00:00:52,710 --> 00:01:01,620
With dashes between and the D and on the score, our minutes, seconds on the score.

11
00:01:01,830 --> 00:01:04,050
And finally, the existing file name.

12
00:01:04,470 --> 00:01:07,890
So that is for all December, November.

13
00:01:08,250 --> 00:01:13,050
So December here, November here, that's the output of the exercise.

14
00:01:13,860 --> 00:01:20,670
But now, of course, I want to show you first how you get the date when the file was created.

15
00:01:21,150 --> 00:01:33,480
So I'm going to import Pav and also from date time, import date time, which allows us to apply data

16
00:01:33,480 --> 00:01:34,380
time operations.

17
00:01:35,190 --> 00:01:38,880
You see what that consists of in this video.

18
00:01:39,570 --> 00:01:43,430
So if we have a path object, let's pick one of these.

19
00:01:43,440 --> 00:01:51,240
I'm not going to solve the exercise here, but just work on one single file such as Files Dec.

20
00:01:52,170 --> 00:02:03,660
A 16, if you have a path object, you could get data about that object using path, that's that methods.

21
00:02:04,820 --> 00:02:10,130
And if you print that ultimate, so the stats variable and run.

22
00:02:11,720 --> 00:02:13,010
This is the outfit we get.

23
00:02:13,910 --> 00:02:16,940
So basically, we have a list of different.

24
00:02:17,970 --> 00:02:22,690
Attributes over the file in this case, it is a.

25
00:02:25,240 --> 00:02:31,750
So you have estimates which are basically some foul mode bits about permission.

26
00:02:32,470 --> 00:02:34,060
We are not interested on that.

27
00:02:34,210 --> 00:02:42,250
Now some identified also not interested in that and identify again about the device.

28
00:02:43,030 --> 00:02:45,220
This is about hard links of the file.

29
00:02:45,850 --> 00:02:53,050
This is about the user identifier, the user group identifier also, and this is about the file size.

30
00:02:53,260 --> 00:02:55,570
So this 8.60 is empty.

31
00:02:55,570 --> 00:03:01,210
Therefore, we give zero as bytes, but if you add some characters and run again.

32
00:03:03,080 --> 00:03:14,360
This gets up to two, so two bites, then we have three values fourth time, a state time as the time

33
00:03:14,360 --> 00:03:23,090
and as this time as state time gives us the most recent timestamp when the file was accessed.

34
00:03:23,870 --> 00:03:25,070
This is a value now.

35
00:03:25,070 --> 00:03:33,340
This is seconds and these seconds actually are seconds from 1st of January 1970.

36
00:03:33,350 --> 00:03:34,100
That's a year.

37
00:03:35,000 --> 00:03:36,140
So it's a time stamp.

38
00:03:36,140 --> 00:03:43,280
It is in second, whether we can convert it into normal date time and then we have as team time.

39
00:03:43,910 --> 00:03:51,470
This shows when the file was last modified, the content when it was modified.

40
00:03:52,580 --> 00:03:56,850
And then lastly, we have the time when the file was first created.

41
00:03:56,870 --> 00:03:59,330
So this is also the one we're going to use.

42
00:03:59,780 --> 00:04:05,120
So let's go back to the script and to get that seat time.

43
00:04:05,570 --> 00:04:15,590
We can create a new variable Letson name this variable second created and that's equal to stats that

44
00:04:16,010 --> 00:04:19,040
I see on the score as time.

45
00:04:19,310 --> 00:04:22,940
This is a property, so no parentheses with this one.

46
00:04:23,210 --> 00:04:24,680
And let's bring it out here.

47
00:04:25,100 --> 00:04:32,680
Second, created so that should give you those same seconds that we got here.

48
00:04:32,690 --> 00:04:41,360
That's and that's now let's convert those seconds into a real time stamp, which can be read by humans

49
00:04:41,360 --> 00:04:43,040
and not by computers.

50
00:04:43,570 --> 00:04:48,290
Sue, they'd created equal ciudades time.

51
00:04:49,730 --> 00:04:55,970
So now we're using that's date time object dot from time stamp.

52
00:04:56,360 --> 00:05:01,670
That's a method of date time and it gets those seconds.

53
00:05:03,130 --> 00:05:07,170
That we produce above created, right?

54
00:05:07,660 --> 00:05:09,040
So putting that out.

55
00:05:12,740 --> 00:05:13,160
Ron?

56
00:05:14,170 --> 00:05:22,630
And we're here, so that's the date, year, month and day and how and minutes and seconds.

57
00:05:23,290 --> 00:05:26,910
Yeah, that's the second decimal points.

58
00:05:26,920 --> 00:05:27,430
No.

59
00:05:27,670 --> 00:05:28,030
So.

60
00:05:29,160 --> 00:05:35,490
Now, the problem is, this is not a strength, and we need it as a streaming rights in order to use

61
00:05:35,490 --> 00:05:37,110
it as a file name later on.

62
00:05:37,410 --> 00:05:43,740
So if you want to convert it into a shrink, you want to see another variable that's created SDR for

63
00:05:43,740 --> 00:05:46,770
streaming that's equal to date created.

64
00:05:47,130 --> 00:05:53,220
That's SDR f time, which means streaming from time.

65
00:05:53,580 --> 00:05:55,980
And here comes a long string.

66
00:05:56,220 --> 00:06:00,600
So you want to define what formats you want to display that string.

67
00:06:00,870 --> 00:06:08,040
So if you want first to show that the year you want to see percentage, why then do you prefer a dash

68
00:06:08,040 --> 00:06:10,020
or two dashes or on their school?

69
00:06:10,290 --> 00:06:14,970
You can put everything here after a three year old preferred to put in a dash.

70
00:06:15,540 --> 00:06:25,260
So we have here and then we have month lowercase m a then maybe another dash around the day with D,

71
00:06:26,070 --> 00:06:33,470
then perhaps we want another school that starts the hover, maybe a column here for time.

72
00:06:33,810 --> 00:06:34,830
It makes more sense.

73
00:06:35,430 --> 00:06:37,050
But again, it's your choice.

74
00:06:37,830 --> 00:06:44,190
Whatever symbol you want to put between these items and minutes with become a column.

75
00:06:45,290 --> 00:06:53,810
And as for seconds, Sue printed out print date created as the are run.

76
00:06:55,920 --> 00:07:01,710
And that's the string, so that that's three now, and we can use that as a file name.

77
00:07:02,770 --> 00:07:04,840
And that's concludes this video.

78
00:07:05,380 --> 00:07:16,470
So again, if you want to do this exercise, you'd have to completed by renaming all these files.

79
00:07:18,890 --> 00:07:23,390
So from aid, the taxi beat a taxi to this format.

80
00:07:24,200 --> 00:07:26,420
Yeah, good luck with exercise and I'll talk to you later.

81
00:07:26,700 --> 00:07:26,900
Sue.

