Set file timestamp from another file.

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Set file timestamp from another file.

Postby NewBorn » Mon May 29, 2023 10:15 am

I have video files in .MKV extension, then i used batch conversion inside AviDemux to save them with .MP4 extension (not a simple rename have to change container format :)

But i have lost original timestamp that my camera make (Date Modified). Before i delete .MKV files i want to copy date modified to the .MP4 files, how can i do it?

I have following file structure.

c:\videos\0001.mkv
c:\videos\0002.mkv
c:\videos\0003.mkv
c:\videos\mp4\0001.mp4
c:\videos\mp4\0002.mp4
c:\videos\mp4\0003.mp4
NewBorn
 
Posts: 18
Joined: Sun Mar 01, 2020 9:22 am

Re: Set file timestamp from another file.

Postby therube » Mon May 29, 2023 5:29 pm

For an individual file, or for a few individual files, I might use something like:

SETTIME.bat:
Code: Select all
@ECHO OFF

ECHO  SETTIME  sets a file's date to the "same" file, named "abc"
ECHO  a sort of more current variation of my old ancient DOS settime program
ECHO.
ECHO  therube 02/20/2015
ECHO.
ECHO  File to change the date of:
ECHO     %1

FOR   %%i in (%1) do  SET   BASENAME=%%~dpiabc
ECHO  reference file (aka "abc"):
ECHO     "%BASENAME%"
ECHO.
ls -l %1
ls -l "%BASENAME%"
ECHO.

PAUSE

touch %1 --reference="%BASENAME%"
:: ls -l %1
c:\bin\dd.exe -1 %1

PAUSE
EXIT

Basically it sets a files "date" to that of some other file.
(In this particular case, it is a file named [hardcoded as] "abc" - though you could point to some other [variable] file instead.)
(touch, is a UNIX command to set a file date.)


Depending... instead of Avidemux, you could automate a batch file to transcode (& date).

pseudo-code:
Code: Select all
for i in videos/*.mkv
do
ffmpeg -i %i.mkv -c copy c:/videos/mp4/%1.mp4
touch c:/videos/mp4/%1.mp4 --reference %1
done

That says (for ffmpeg) to copy 0001.mkv to 0001.mp4, & (touch to) set 0001.mp4's file date to that of 0001.mkv.
(Likewise, it would do it for 0002...).


Any particular reason that you are transcoding from .mkv to .mp4?
(The only reason I would do such, is if the particular device you are playing on does not support .mkv, or if on the off chance, your device/player might happen to play mp4 "better" the mkv.)
If it is because your player does not support .mkv, get a new player ;-).)
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm


Return to BRU Support