In said:
charles [
[email protected]] posted:
I need to do a mass string replace in a large number of files
under Windows2000. The problem is that I also need to preserve
the original create, modified, access dates in those files.
I am drawing a blank on how I would go about doing this and would
appreciate any suggestions.
You might be able to use CygWin's touch.exe utility
(
www.cygwin.com). Try this:
* Make a backup of all your files in a folder called C:\BACKUP
(for example).
* Do your mass string replace.
* Make a batch file that centers around "touch -r FILENAME
C:\BACKUP\FILENAME". This updates the times on the file using
C:\BACKUP\FILENAME (the original file) as a reference. You should
be able to use %1 to do them one at a time, or something more
creative like "for %%i in (c:\path) do touch -r %%i
C:\BACKUP\%%i".
I agree with your methodoly but will not be tackling the batch file.
<G>
Just for reference, the touch.exe in the Win32 Console Toolbox at
http://stevemiller.net/apps/
can definitely address these options.
=====
C:\>touch /?
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.