Last active
August 14, 2020 08:06
-
-
Save ghotz/549b9129824e37f274b141d9f73ed752 to your computer and use it in GitHub Desktop.
Extract Creation/Encoded date/time from DVCAM AVI or HDC M2T files, set it to file creation/modified date time and add it as a prefix to filename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Extract DV AVI Creation date/time, set it to file creation/modified date time and add it as a prefix to filename | |
| # Needs Medianfo CLI executable from https://mediaarea.net/en/MediaInfo/Download/Windows | |
| # Note: -LiteralPath is used because directory names have [] characters | |
| dir -LiteralPath 'Z:\Videos' -Include *.avi | % { | |
| $CreationDate = & C:\utils\mediainfo\MediaInfo.exe --Inform="General;%Recorded_Date%" "$($_.FullName)"; | |
| $_.CreationTime = [datetime]$CreationDate; | |
| $_.LastWriteTime = [datetime]$CreationDate; | |
| $prefix = $CreationDate -replace '-|:|.000','' -replace " ", "-"; | |
| Rename-Item -LiteralPath $_.FullName ($prefix + '-' + $_.Name); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Extract HDV m2t Creation date/time, set it to file creation/modified date time and add it as a prefix to filename | |
| # Needs Medianfo CLI executable from https://mediaarea.net/en/MediaInfo/Download/Windows | |
| # Note: -LiteralPath is used because directory names have [] characters | |
| dir -LiteralPath 'Z:\Videos' -Include *.m2t | % { | |
| $CreationDateStr = & C:\utils\mediainfo\MediaInfo.exe --Inform="General;%Encoded_Date%" "$($_.FullName)"; | |
| $CreationDateUtc = [DateTime]::SpecifyKind(($CreationDateStr -replace 'UTC', ''), [DateTimeKind]::Utc); | |
| # you need to know the time zone where the video was recorded | |
| $CreationDateAtRecordingSite = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId($CreationDateUtc, 'Central European Standard Time') | |
| $_.CreationTime = $CreationDateAtRecordingSite; | |
| $_.LastWriteTime = $CreationDateAtRecordingSite; | |
| $prefix = $CreationDateAtRecordingSite.ToString('yyyyMMdd-HHmmss'); | |
| Rename-Item -LiteralPath $_.FullName ($prefix + '-' + $_.Name); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment