Batch file to clone timestamps from one set of files to another?


Recommended Posts

This may seem like a weird task, but I need to do it.

 

I have a ton of videos I have converted.  Source files are various formats, new files are all mp4.  File names of each of the new files are identical to the originals except for the extension.

 

I would like a way to have a batch file automatically take the timestamps (created/modified/accessed) from the individual, original files and clone them to the new files.

 

video1.wmv --> video1.mp4

video2.avi    --> video2.mp4

video3.mp4  --> video3.mp4

(etc.)

 

I have intermidiate experince with batch scripts, but I'm having difficulty finding out if this task is possible.  Any help is appreciated.

Link to comment
Share on other sites

I'm not an expert in Powershell by any means, but you can use this to clone those parameters onto a new file.

 

$(Get-Item NEWFILE).CreationTime=$(Get-Item OLDFILE).CreationTime
LastWriteTime and LastAccessTime will take care of the other attributes you mentioned.

I'd guess you'd need to use ForEach-Object to run through all the files.

Link to comment
Share on other sites

I don't know anything about Powershell.  What you have there looks like NEWFILE and OLDFILE would need to be manually entered.  A function called ForEach-Object would be added to automate the process for files with identical file names.  Is that right?

Link to comment
Share on other sites

Was able to do it with exiftool in a batch file.

 

exiftool.exe -tagsFromfile "C:\%%f.avi" -FileAccessDate -FileCreateDate -FileModifyDate -ext mp4 "C:\Folder with files to be changed"

 

Though, the File Access Date doesn't really work.  It set the last accessed times to the same values as the last modified values. Works well enough, I guess.

 

Thanks for the suggestion, though.

Link to comment
Share on other sites

This topic is now closed to further replies.