Subscribe to Windows IT Pro
September 13, 2004 12:00 AM

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

Windows IT Pro
InstantDoc ID #81784
Rating: (0)


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 (stevemil@pobox.com).  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.



Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.