How do I get this property by using Power Shell?

75 Views Asked by At

The details of my problem:

I have some .m4a recording files. I can use the Explorer to get detail from Properties > Details > Origin > Media created. But as you may know, the Properties window does not show time in HH:MM:SS format but only in HH:MM, and I do need the second very much.

I learned a way to fetch info by Power Shell code something like this:

(Get-Item C:\Users\natsu\Desktop\FolderName\RecordingFile.m4a).VersionInfo | select Media created

But, select Media created returns an error, select "Media created" returns blank value. I can avoid the space in the path but I don't know how to escape it in the command.

May you please help me: (1) Try telling me the correct command for the Power Shell. or (2) Other Applications that can read it in HH:MM:SS format?

This may look so silly and simple for you but please consider that I am not a professional user. Sorry for my bad English. Any help would be appreciated and thanks in advance.

What did I try:

I did try sttmedia but this application does not support the Media created property.

I did try Explorer++ but this application can only show in HH:MM format too.

What am I expecting:

I want to get my .m4a files, for the Media created property, in HH:MM:SS format.

1

There are 1 best solutions below

0
ZivkoK On

Get-FileMetaData uses the object/function $ShellFolder.GetDetailsOf() to retrieve the information which returns string values. That's why it's not getting the 'seconds' information you need.

You can use the ExtendedProperty of the $ShellFile object which will return a DateTime object instead.

The Media Created corresponds to the DateEncoded property. You can either use its 'Attribute Path/Name' or 'Format Identifier/Property ID' pair. Information can be found here: Property System Reference

Here is a code example (note that the value returned is in UTC format):

$Targetfile  = "C:\Temp\SAMPLE.m4a" ;

$FileInfo    = Get-ItemProperty -Path $Targetfile ;
$ShellApp    = New-Object -ComObject Shell.Application ;
$ShellFolder = $ShellApp.Namespace($FileInfo.Directory.FullName) ;
$ShellFile   = $ShellFolder.ParseName($FileInfo.Name) ;

# Get Attribute Value and Check the Type of Data returned:
Write-Host 'Using $ShellFile.ExtendedProperty with Attribute Name (data in UTC format)' -ForegroundColor Green ;
$Value = $ShellFile.ExtendedProperty("System.Media.DateEncoded") ;
Write-Host " Media Created: $($Value)`n Property Type: $($Value.GetType().FullName)" ;
Write-Host ;

Write-Host 'Using $ShellFile.ExtendedProperty with FMTID/ID (data in UTC format)' -ForegroundColor Green ;
$Value = $ShellFile.ExtendedProperty("{2E4B640D-5019-46D8-8881-55414CC5CAA0} 100") ;
Write-Host " Media Created: $($Value)`n Property Type: $($Value.GetType().FullName)" ;
Write-Host ;

You can add this code to compare the data returned by the function ShellFolder.GetDetailsOf():

# In comparison to the $ShellFolder.GetDetailsOf()
Write-Host 'Using $ShellFolder.GetDetailsOf function (data in GMT+X format)' -ForegroundColor Green ;
$Value = $ShellFolder.GetDetailsOf($ShellFile, 208) ;
Write-Host " Media Created: $($Value)`n Property Type: $($Value.GetType().FullName)" ;
Write-Host ;