Search code examples
windowspowershelldatetimentfsmicrosoft-file-explorer

Powershell not setting exact modified time?


So I don't really mind and it's not super important but I wrote a powershell script to set the time of a codec converted family film. The original files ext been named to MP44 and the resulting files ext are MP4. I just want to understand why the times are not exactly the same.

explorer file dates don't match

 Directory of C:\Users\zzz\Desktop\family videos and images\hero 2021

2022-03-18  05:24 PM    <DIR>          .
2022-03-16  07:18 AM    <DIR>          ..
2020-09-02  07:15 PM        79,353,358 ffmpeg.exe
2020-09-02  07:15 PM        79,214,606 ffplay.exe
2020-09-02  07:15 PM        79,249,422 ffprobe.exe
2022-03-16  09:45 PM               482 go.bat
2021-12-24  09:14 PM     4,000,895,516 GX010066.MP44
2021-12-24  09:14 PM       741,345,212 GX010066.MP44.ffmpeg.mp4
2021-12-24  10:25 PM     4,003,210,355 GX010067.MP44
2021-12-24  10:25 PM       687,471,776 GX010067.MP44.ffmpeg.mp4
2021-12-24  09:15 PM     4,001,034,065 GX020066.MP44
2021-12-24  09:15 PM       719,404,024 GX020066.MP44.ffmpeg.mp4
2021-12-24  10:27 PM     3,629,297,689 GX020067.MP44
2021-12-24  10:27 PM       635,027,797 GX020067.MP44.ffmpeg.mp4
2021-12-24  09:17 PM     4,000,513,626 GX030066.MP44
2021-12-24  09:17 PM       690,608,291 GX030066.MP44.ffmpeg.mp4
2021-12-24  09:17 PM       714,946,960 GX040066.MP44
2021-12-24  09:17 PM       125,647,486 GX040066.MP44.ffmpeg.mp4
2022-03-18  05:36 PM               537 timechanger.ps1
              17 File(s) 24,187,221,202 bytes
               2 Dir(s) 

Directory shows same times/dates.

I guess it's more of a windows question than a powershell question.  Why would explorer show different modified dates?

Here is my powershell for posterity:

 $files = Get-ChildItem  *.mp44 | select Name, LastWritetime
foreach ($file in $files) { 
                $currentname = $file.name
                #$currentname
                $currentsubstring = $currentname.substring(0,8)
                #$currentsubstring
                $WriteTime = $file.LastWritetime
                #$WriteTime
                write-host "Going to get-item $currentsubstring.MP44.ffmpeg.mp4 and set $Writetime"
                $targetfile = "$currentsubstring.MP44.ffmpeg.mp4"
                $Targettime = $Writetime
                $bacon = Get-Item $targetfile
                $bacon.LastWritetime = $targettime
                }

Thanks in advance for your time and assistance.


Solution

  • Because the 'Date' column in Windows Explorer that you have showing there is the Creation Date property, not the Last Modified Date.

    enter image description here

    Notice how the "Date" column matches the "Date created" column, not the "Date modified" column in my screenshot.