Skip navigation

JSI Tip 8460. How can I modify a files timestamp?


If you wish to set a files 'date modified' timestamp to the current date and time, you can use native commands. To modify the 'date modified' timestamp of H:\Folder\FileName.ext:

pushd H:\Folder
copy /b /y "FileName.ext" +,,
popd

NOTE: The archive bit is NOT set.

If you wish more control, use Touch.exe:

===============================================================================

Description: Touch displays or sets the created, access, and modified times of one or more files.

-------------------------------------------------------------------------------

Touch for Win32, Version 1.0
Freeware by Steve P. Miller ([email protected]).  Copyright 1997.
Visit http://pobox.com/~stevemil for the latest version and other utilities.

Usage: touch \[/s\] \[/h\] \[/p\] \[/q\] \[/v\] \[/c\] \[/m\] \[/a\] \[/r file\]
             \[/d mm-dd\[-\[cc\]yy\]\] \[/t hh\[:mm\[:ss\[.ms\]\]\]\] filespec ...

  /s Process subdirectories.
  /h Process hidden/system files/directories.
  /p Prompt for each file (Yes/No/All/Quit). Ignored in view mode.
  /q Quiet mode; Only display errors; Ignored in view mode.
  /v View mode; Display times rather than set times.
  /c View/set created time.
  /m View/set modified time; Default if /a and /c are not specified.
  /a View/set accessed time.
  /r Reference file; Use this file's date and time to set other files.
  /d Date: month, day, century, year.
  /t Time: hour (0-24), minutes, seconds, milliseconds.

In view mode (/v), the /p, /q, /r, /d, and /t options are ignored.
In set mode, the default is to use the current date and time.
Use the /r, /d, and/or /t options to override the default set time.
The century (cc) is assumed to be 19 for years 69-99, and 20 for years 00-68.



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish