Home > Blockchain >  Using Batch to copy file attributes (at least Created,LastWrite,LastAccess) from 1 file to a 2nd
Using Batch to copy file attributes (at least Created,LastWrite,LastAccess) from 1 file to a 2nd

Time:01-21

I am trying to copy attributes for *.mkv *.mp4 video files. I have found a way to copy file attributes, but it is quite slow as it is calling Powershell to use it commands.

powershell ^(ls '!orig-file!'^).CreationTime = ^(ls '%%I'^).CreationTime
powershell ^(ls '!orig-file!'^).LastWriteTime = ^(ls '%%I'^).LastWriteTime
powershell ^(ls '!orig-file!'^).LastAccessTime = ^(ls '%%I'^).LastAccessTime
...................
%%I equals new-file for each FOR loop iteration

Is there a way to do this faster without Powershell?

Otherwise, I assume it would be possible to only call Powershell once and copy all 3 or more attributes in 1 line? I'am assuming that reading each file attribute individually is the only way to copy, but I would prefer all attributes if there are any more to copy.

EDIT: FULL CODE: (with all remarked/commented lines removed) ( Batch Convert Videos audio from one format to another )

@ECHO OFF
SETlocal

SET drive="~dp0"
SET string=           
  • Related