The easiest way to change the creation/modification timestamps would
be to use a utility. I've written one that will do what you ask, and
I would be happy to share it with you. Here's a sample script using
my DTstamp utility:
@echo off
:: etouch.bat by Eric Langland
:: Change a file's timestamp to the current date and time
IF "%1"=="" ECHO Usage: etouch filespec & GOTO:EOF
:: Get the date
FOR /F "tokens=2" %%A IN ('ECHO %DATE%') DO SET MyDate=%%A
:: Get the time
FOR /F "tokens=1 delims=." %%A IN ('ECHO %TIME%') DO SET MyTime=%%A
ECHO Current date/time is %MyDate% %MyTime%
ECHO/
:: Change the timestamp
ECHO Updating the timestamp on %~1 ...
C:\utils\dtstamp "%~1" -w -d %MyDate% -t %MyTime%
...and here's the syntax for DTstamp.exe:
C:\Scratch\Test Stamp Files>c:\utils\dtstamp /?
DTstamp version 1.1 by Eric Langland, 2003
Lists or changes date and time stamps on files.
Usage: DTstamp [drive:][path]filename -C -W -A -D date -T time -ISO
-FAT
-C List or change Creation date and/or time.
-W (default) List or change last Write date and/or time.
-A List or change last Access date and/or time.
-D date Change the date.
-T time Change the time.
-ISO List dates in ISO format (YYYY-MM-DD).
-FAT Attempt to list/change creation time or last access
time on
non-NTFS drives, even if not supported by the file
system.
Notes:
The filename is the only mandatory parameter. Wildcards ? and * are
accepted.
UNC network paths like \\server\share\subdirectory are accepted.
The -C, -W and -A parameters may be used in any combination. If -C,
-W and -A
are not specified, then -W is assumed.
Dates and times can be entered in a wide range of formats.
Omit both date and time to list the current date/time stamps.
My utility is not available for download because I don't have a
server, but I could email it to you if you like. Others have written
similar utilities. You might try Steve P. Miller's touch.exe, which
has more features than my utility. Steve's download page is
http://stevemiller.net/apps/ and touch.exe is part of his Win32
Console ToolBox.
Hope that helps,
Eric
"hon" <
[email protected]> wrote in message
hi all,
I would like to change a file's (such as text file) timestamp(the date and
time created or modified ) by script , how can i do that ?
thanks a lot