Skip to content

Instantly share code, notes, and snippets.

@PureOcean
Last active April 24, 2022 01:43
Show Gist options
  • Save PureOcean/58a802c0cc23441dda108a96152fc9de to your computer and use it in GitHub Desktop.
Save PureOcean/58a802c0cc23441dda108a96152fc9de to your computer and use it in GitHub Desktop.
MKVToolnix doesn't support remux the output file as the same date as the original input file. This script sets the output file date according to original date of the input file.
@echo off
cd /d "%~dp0"
:: Unfortunately, MKVToolnix doesn't support remux the output file as the same date as the original input file.
:: This script sets the output file date according to original date of the input file. How does it work?
:: It works by selecting one or many files and dragging and dropping them onto this script.
:: Coded by PureOcean (2022-04-23+24)
:: Thanks to the commands: https://github.com/gus33000/ESD-Decrypter/blob/master/bin/Rebuild-ISO.ps1#L190=
set "MKVToolNixPath=D:\Program\MKVToolNix"
set "InputFile=%~dpnx1"
set "OutputFile=%~dpn1_remux.mkv"
"%MKVToolNixPath%\MKVmerge.exe" --output "%OutputFile%" ( "%InputFile%" )
ECHO.
powershell -c "$CreationTimeStamp = Get-ChildItem '%InputFile%' | %% {[System.TimeZoneInfo]::ConvertTimeToUtc($_.CreationTimeUtc).ToString('MM/dd/yyyy,HH:mm:ss')}; Set-ItemProperty -Path '%OutputFile%' -Name CreationTimeUtc -Value $CreationTimeStamp; $LastWriteTimeStamp = Get-ChildItem '%InputFile%' | %% {[System.TimeZoneInfo]::ConvertTimeToUtc($_.LastWriteTimeUtc).ToString('MM/dd/yyyy,HH:mm:ss')}; Set-ItemProperty -Path '%OutputFile%' -Name LastWriteTimeUtc -Value $LastWriteTimeStamp;"
ECHO.
pause
exit /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment