This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Time Stamps For Executables?


I am having a similar problem with the touch command.
It is NOT modifying the Create and Modify times of
a file.
A while back I had a virus which set the dates
on the windows dir and everyting beneath it to
the year 2031. So, Since I wanted to restore them
to as cloase as the time I installed the system,
I used a script to find and touch these files.

After script was done, ls -l showed still the year 2031.
So, what can I resort to to rstore the creation
and modification times to more sane values?

Here is the script I used:

#!/usr/bin/bash

cd /cygdrive/c/windows

# ff is a file with the date when I installed the system.
# So anything newer in change and modification
# times, will be saved in /tmp/$$
# I chose the hour 12 pm as the time.

find . -newercm /tmp/ff -print > /tmp/f$$

while [ true ]; do
	read filename
	[ "x$filename" = "x" ] && break
	if [ -d "$filename" ]; then
		ll=`ls -ld "$filename"`
	else
		ll=`ls -l "$filename"`
	fi
	year=`echo $ll | awk '{ print $8 }'`
	day=`echo $ll | awk '{ print $7 }'`
	month=`echo $ll | awk '{ print $5 }'`
	if [ "$year" = "2031" ]; then
		case $month in
			Jan) mm=01 ;;
			Feb) mm=02 ;;
			Mar) mm=03 ;;
			Apr) mm=04 ;;
			May) mm=05 ;;
			Jun) mm=06 ;;
			Jul) mm=07 ;;
			Aug) mm=08 ;;
			Sep) mm=09 ;;
			Oct) mm=10 ;;
			Nov) mm=11 ;;
			Dec) mm=12 ;;
		esac
		case $day in
			1|2|3|4|5|6|7|8|9)
			   dd=0$day ;;
			*) dd=$day ;;
		esac
		touch -acm -t 2003$mm$dd1200  "$filename"
	fi
done < /tmp/f$$

Cheers,

Joe

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]