Help: preserve file dates

  • Thread starter Thread starter charles
  • Start date Start date
C

charles

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.

Thanks for any info.
 
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".

HTH,

ws
 
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.
 
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>

This exercise is left for the reader. :)
Just for reference, the touch.exe in the Win32 Console Toolbox at
http://stevemiller.net/apps/
can definitely address these options.

Nice - wasn't aware of this port of TOUCH. Very handy utility.

ws
 
Thanks both Mark V and wadester for the help. The version of touch I had
did not have the -r /r switch. That switch turns an ordeal into 1 line
of code. :)

Great! Thanks!
 
charles wrote in message said:
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.

Thanks for any info.

Impossible without external tools or debug.exe
 
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.

Thanks for any info.

EDLIN (standard distribution) and TOUCH (Resource Kit and other sources,
e.g. AINTX) should get you started.
 
charles said:
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.

ReplaceEm is a free GUI file/replace utility that preserves timestamps by default.
It also accepts commandline parameters. And it doesn't need to be installed (IOW,
one can run it from their 'Utils' CD).

http://www.orbit.org/replace/
 
ReplaceEm is a free GUI file/replace utility that preserves timestamps by default.
It also accepts commandline parameters. And it doesn't need to be installed (IOW,
one can run it from their 'Utils' CD).

http://www.orbit.org/replace/

Thanks for the suggestion Ritchie. However the replacement matter was
binary and the only tool I found to handle it was snr61
<http://www.student.northpark.edu/pemente/sed/snr61sw.zip>. It looks to
be abandoned? shareware with fragile filename handling but did the
one-time job fine along with Steve Miller's touch program.
 
Back
Top