I have been trying to write a Powershell script based on some code online that will read the metadata info from picture, video and other files and then sort them based on on
When I run your code, $objFolder.GetDetailsOf($objFolder.Items().Item(0), 12) I get an empty string. I even changed the item number and the folder I was looking in to make sure I was getting a file object.
However if I do this:
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.namespace("C:\Temp")
$date = $objFolder.Items().Item(3).ModifyDate
I get a value that is already a DateTime object.
(the code above uses my folder and item index)
I wanted to know what the extra characters were ( you dont mention already looking at this. ). I Updated your array code $datearray += $date[$i] to $datearray += [int][char]$date[$i]. The truncated output showed two oddities 8207 and 8206 which translate to left-to-right mark and right-to-left mark. They are normally associated with html. Unfortunately i cannot provide insight to their presense. Good news is that they are easy to remove.
$date = ($date -replace [char]8206) -replace [char]8207
[datetime]::ParseExact($date,"g",$null)
Which nets the output
Thursday, March 26, 2009 1:43:00 PM
Hopefully this is a little bit closer of what you wanted. I tried searching for reasons for the presence of those ascii codes but i didn't find anything useful.
Extra Information for other readers
I did this since i didnt know what the index 12 was. So i made an array that contains the friendly names of all the file meta data possible (288 entries!). I have the here-string located here for brevity.
With this i was testing the following code against a picture of mine.
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.namespace("C:\Temp\")
0..$Meta.GetUpperBound(0)| %{
$metaValue = $objFolder.GetDetailsOf($objFolder.Items().Item(2), $_)
If ($metaValue) {Write-Host "$_ - $($meta[$_]) - $metaValue"}
}
$Meta is the array i spoke of earlier.
The code will cycle though all the details of my file, indicated by Item(2), writing to screen all file details that contain values. In the end there is a line converting the string to a date value. Script output below
0 - Name - IMG_0571.JPG
1 - Size - 3.12 MB
2 - Item type - JPEG image
3 - Date modified - 3/26/2009 3:34 PM
4 - Date created - 8/24/2014 5:19 PM
5 - Date accessed - 8/24/2014 5:19 PM
6 - Attributes - A
9 - Perceived type - Image
10 - Owner - TE_ST\Cameron
11 - Kind - Picture
12 - Date taken - 3/26/2009 1:43 PM
19 - Rating - Unrated
30 - Camera model - Canon EOS DIGITAL REBEL XS
31 - Dimensions - 3888 x 2592
32 - Camera maker - Canon
53 - Computer - TE_ST (this computer)
155 - Filename - IMG_0571.JPG
160 - Bit depth - 24
161 - Horizontal resolution - 72 dpi
162 - Width - 3888 pixels
....output truncated....
247 - Program mode - Normal program
250 - White balance - Auto
269 - Sharing status - Not shared