Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Creation Date of Video Files 1

Status
Not open for further replies.

Error7

Programmer
Jul 5, 2002
656
GB
After copying a few hundred .MP4 and .MOV files from various devices, I found that Windows incorrectly displays the 'Date Created' as the last modified date. I need to edit the video files in chronological order but despite many on-line searches to find a VB6 solution to viewing the actual Date Created I have drawn a blank.

Does anybody have any code snippets available to achieve this?

[gray]Experience is something you don't get until just after you need it.[/gray]
 
I found this on a different forum:
Code:
Dim myFSO As Object
Dim f As Object

Set myFSO = CreateObject("Scripting.FileSystemObject")
Set f = myFSO.GetFile("c:\test.txt")
    
Debug.Print f.DateCreated

I haven't tested this.
 
This works for me:

Code:
Dim FS As Object
Dim f

Set FS = CreateObject("Scripting.FileSystemObject")
Set f = FS.GetFile("C:\TEMP\One.docx")

Debug.Print "              Size: " & f.Size
Debug.Print "      Date Created: " & f.DateCreated
Debug.Print "Date Last Accessed: " & f.DateLastAccessed
Debug.Print "Date Last Modified: " & f.DateLastModified
Debug.Print "              Type: " & f.Type


---- Andy

There is a great need for a sarcasm font.
 
Thanks but I already tried this code and lots of similar. It gives the output:
Date Created: 20/02/2020 11:57:41
Date Last Accessed: 20/02/2020 16:04:53
Date Last Modified: 10/02/2020 13:28:16
Type: MOV Video File (VLC)
Whereas I know that the original creation date is 29/01/2020.

This is the problem Windows doesn't retain the actual creation date when a file is copied from a device.

I thing the actual creation date is embedded as exif data in the video file. I can read exif data in Jpg's but I can't figure out how do this with video files.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
AFAIK, the 'date created' is a date when file was recorded in current file system, if some date is encoded in exif data, you have to access exif instead.

combo
 
Thanks for your input combo, that's exactly what I meant when I said "I think the actual creation date is embedded as exif data in the video file. I can read exif data in Jpg's but I can't figure out how do this with video files."

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Windows can read this info, so you can try to use Shell object and see where required data is stored. For testing it, early binding to Shell32, sInputFileName and sInputFilePath (terminated with \) are short name and path of file:
Code:
Dim oShell As Shell32.Shell
Dim oShFolder As Shell32.Folder
Dim oShFolderItem As Shell32.FolderItem

Set oShell = New Shell32.Shell
Set oShFolder = oShell.Namespace(sInputFilePath)
Set oShFolderItem = oShFolder.Items.Item(sInputFileName)

For i = -1 To 100 ' hope this is sufficient
    desc = oShFolder.GetDetailsOf(0, i)
    If desc <> "" Then
        Debug.Print x, desc, oShFolder.GetDetailsOf(oShFolderItem, i)
    End If
Next


combo
 
Thanks, just noticed x instead i in Debug.Print, so revised line, with no empty data printed (also, there is some info above i=100, the saerching loop should be wider):
[pre] If oShFolder.GetDetailsOf(oShFolderItem, i)<>"" Then Debug.Print i, desc, oShFolder.GetDetailsOf(oShFolderItem, i)[/pre]

combo
 
You beat me to it - I was just about to say that 100 wasn't enough. I suspect the OP is looking for the extended property at index 208 ("Media created"). One problem is that the data retrieved via GetDetails is sometimes not in quite the format VBA likes ... might be better to go via the ExtendedProperty, but for that you need to know the correct PropertyKey - and I've never found a way of enumerating those from VB (not to say it can't be done, though), so yuo'll need to refer to
We can then use something like:

Code:
[blue]Const MediaCreated = "{2E4B640D-5019-46D8-8881-55414CC5CAA0} 100"
With New Shell32.Shell
    Debug.Print .Namespace(sInputFilePath).Items.Item(sInputFileName).ExtendedProperty(MediaCreated)
End With[/blue]
 
Thanks for your excellent example combo.
I tried extending the loop to 150 but all the fields beyond 28 are blank. I assume they don't contain any data but I am only interested in item 3 anyway, which is the actual creation date & time and not the modified date as listed.

0 NameIMG_3787.MOV
1 Size63.8 MB
2 Item typeMOV Video File (VLC)
3 Date modified30/01/2020 10:56
4 Date created21/02/2020 15:21
5 Date accessed21/02/2020 15:21
6 AttributesA
7 Offline status
8 Offline availability
9 Perceived typeVideo
10 OwnerAdministrators
11 KindVideo
12 Date taken
13 Contributing artists
14 Album
15 Year
16 Genre
17 Conductors
18 Tags
19 RatingUnrated
20 Authors
21 Title
22 Subject
23 Categories
24 Comments
25 Copyright
26 #
27 Length00:00:34
28 Bit rate?98kbps
29 ProtectedNo
30 Camera model
31 Dimensions
32 Camera maker
33 Company
34 File description
35 Program name
36 Duration
37 Is online
38 Is recurring
39 Location
40 Optional attendee addresses

I will now build your code into a programme to loop through my video files and rename each file with the date & time of creation.

Thanks for your help with this.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Win 10, old mp4 file, usb disk: properties ended for 320. After driver and network data media data above 300. All properties except first few positions seem to be local.

combo
 
combo, I changed the loop to 320 then tested your code on .MOV, .MP4 and .MTS files, all only list properties up to 286.

276 Complete
277 Task owner
278 Total file size
279 Legal trademarks
280 Video compression {34363248-0000-0010-8000-00AA00389B71}
281 Directors
282 Data rate ?21892kbps
283 Frame height 1080
284 Frame rate ?25 frames/second
285 Frame width 1920
286 Total bitrate ?22148kbps

Thanks anyway.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
>I am only interested in item 3 anyway

No, you are not - or you shouldn't be as 3,4 and 5 represent the same data that you have already rejected, as it is the file system data that you have already indicated is 'wrong'
 
Thanks strongm, I hear what you're saying but item 3, which I know indicates that it's the modified date, is the only item with what I know to be the actual time and date that the file was created.
3 Date modified30/01/2020 10:56
4 Date created21/02/2020 15:21
5 Date accessed21/02/2020 15:21

I know that item 12 has a field for Date taken, but this contains no data.
You previously mentioned that index 208 ("Media created") but using combo's example item 208 is "From"

205 Date received
206 Date sent
207 From addresses
208 From
209 Has attachments
210 Sender address
211 Sender name
212 Store

[gray]Experience is something you don't get until just after you need it.[/gray]
 
>You previously mentioned that index 208 ("Media created") but using combo's example item 208 is "From"

Yes, because in reality it depends ... which is why I provided the example code that does not rely on an index from the shell ...

>I know indicates that it's the modified date

And is the same date as returned by f.DateLastModified in Andrzejek's example, and should be exactly the same as that shown by Windows Explorer. They all come from the same place ...
 
strongm, assuming that this is how I implement your code:

Const MediaCreated = "{2E4B640D-5019-46D8-8881-55414CC5CAA0} 100"
With New Shell32.Shell
Debug.Print .NameSpace("c:\").Items.Item("Video.mp4").ExtendedProperty(MediaCreated)
End With

It doesn't return anything.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Sadly there's no mandatory requirement for a file to provide this data.
 
strongm, does the '100' represent a position in the list?

[gray]Experience is something you don't get until just after you need it.[/gray]
 
I have found a way of finding the Media Created date of a video file by interacting with MediaFile.exe

However, when I try to create a new copy of each file using FileCopy OldFileName, NewFileName I get an Error 52 Bad file name or number.
This is the old file path and name and the old filepath and new name:
OldFileName = E:\Photograph & Video\Caribbean Cruise 2020\All Video's\20200127\IMG_3723.MOV
NewFileName = E:\Photograph & Video\Caribbean Cruise 2020\All Video's\20200127\20200126 123056.MOV

If I hard code the copy command like this: FileCopy "E:\Photograph & Video\Caribbean Cruise 2020\All Video's\20200127\" & OldFileName, "E:\Photograph & Video\Caribbean Cruise 2020\All Video's\20200127\20200126 123056.MOV"
It doesn't produce any errors.

I can't figure out what the problem could be.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top