changing lots of file dates?
Jon LaBadie
ubu at labadie.us
Fri Jul 29 06:32:06 UTC 2022
On Wed, Jul 27, 2022 at 05:57:00PM -0700, rikona wrote:
>I had to do a restore of lots of data files back a bit, from a backup
>disk. That did restore the files, but for some reason the 'modified'
>date for all these files got set to a date way in the past - way earlier
>than the 'create' date. May be 100K files or so. That backup no longer
>exists, so I can't 'redo' the restore to fix the problem.
>
>Is there a way to SAFELY reset all these on the disk using the
>following conditions:
>(1) if the modified date is earlier than the create date, set the mod
>date to the create date.
>(2) if the modified date is later than or = to the
>create date, do not change the mod date.
>(3) do not change any other date, and don't make the mod or access date
>the date when this was done.
There is no simple way I know of to modify mod time without
also setting inode change time to the current time. With that
limitation, you might start with a script like this:
for f
do
stat --printf="%Y %W %w\n" sent | read epmod epbirth birth
if (( epmod < epbirth ))
then
touch --date="$birth" -m sent
fi
done
--
Jon H. LaBadie ubu at labadie.us
More information about the ubuntu-users
mailing list