Sync Timstamp in Linux

First you have to run something along the lines of:-

find . -type f -print -exec stat -t -c '%y' {} ; > /tmp/original_dates.txt

On the first set of files, the ones with the correct time.
Once that is complete you run:-

cat /tmp/original_dates.txt | (while read FILE && read DATE; do echo $FILE; echo $DATE; DATE2=`date -d "$DATE" +%Y%m%d%H%M.%S`; touch -t $DATE2 "$FILE"; done)

On the second set of files. This will then set their date as the original.

Leave a Reply

Your email address will not be published. Required fields are marked *