Jump to content



Photo

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

Answered Go to the full post win7

  • Please log in to reply
3 replies to this topic

#1 unknownsoldierX

unknownsoldierX

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 09-March 05

Posted 04 February 2014 - 04:15

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.



Best Answer unknownsoldierX , 06 February 2014 - 02:51

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.

Go to the full post



#2 zhangm

zhangm

    Just bitter.

  • Tech Issues Solved: 13
  • Joined: 21-August 02

Posted 04 February 2014 - 04:30

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.

#3 OP unknownsoldierX

unknownsoldierX

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 09-March 05

Posted 04 February 2014 - 04:39

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?



#4 OP unknownsoldierX

unknownsoldierX

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 09-March 05

Posted 06 February 2014 - 02:51   Best Answer

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.