News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Change date and time of a file

Started by jj2007, April 28, 2017, 06:35:21 PM

Previous topic - Next topic

jj2007

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
  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 is set to last modified; you can use c instead, but Touch will set the last modified date. TimeSF is documented here.