The MASM Forum

General => The Workshop => Topic started by: jj2007 on April 28, 2017, 06:35:21 PM

Title: Change date and time of a file
Post by: jj2007 on April 28, 2017, 06:35:21 PM
In case you ever saw a need to set a new date for a file (for example, photos rotated in Windows picture viewer...), here is a simple commandline tool. Place it in your SendTo folder. Source (*.asc) and exe attached - use at your own risk.

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  Let esi=CL$()
  .if Exist(esi)
      void GfGetInfo(m)      ; get c=created or m=last modified date
      void TimeSF(Input$("New date & time: ", Cat$(fDate$(xmm0)+", "+fTime$(xmm0))))      ; get new date and translate it
      Inkey "Touch ", esi, CrLf$, "with this new date & time: ", fDate$(xmm0), ", ", fTime$(xmm0), " (y to confirm)?", CrLf$
      .if eax=="y"
            Touch esi, xmm0
            Print "Touched!!!! Hit any key to exit"
      .else
            Print "no changes done"
      .endif
  .else
      Print "Bad commandline: [", esi, "]"
  .endif
  Inkey
EndOfCode

OPT_Arg1      ChangeAndTouch.asc            ; sets commandline for testing in RichMasm


In case you want to build it yourself: Get MasmBasic, open the source in RichMasm, hit F6. The OPT_Arg1 is currently set to the source itself, but any other path will do.

Note GfGetInfo (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1230) is set to last modified; you can use c instead, but Touch (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1054) will set the last modified date. TimeSF is documented here (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1328).