Author Topic: Change date and time of a file  (Read 673 times)


  • Member
  • *****
  • Posts: 8616
  • Assembler is fun ;-)
    • MasmBasic
Change date and time of a file
« 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\      ; download
  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"
            Print "no changes done"
      Print "Bad commandline: [", esi, "]"

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.