0

I'm trying to do almost the same in this question: Rsync : copying over timestamps only

But in this case, some os the files were already modified...

There is any way to change just the timestamp between folder A (original) to B (new one) just by the filename... because filenames is still the same in the 2 places.

i was thinking maybe use touch script, but it seems to be harder, if there is an option using rsync its just one command and Bingo!

Thanks!

1 Answers1

2

rsync doesn't have the ability to do what you are looking for. However, you are in luck because both sets of files are on the same machine, therefore you can use the -r flag of touch to copy the timestamp of one file to another.

You can use find to copy the dates on /source/files and set the timestamps on /files/to/change

This will output the commands that will copy the timestamps, but not actually execute them:

cd /source/files && find . -type f -exec echo touch -r '{}' /files/to/change/'{}' ';'

The output is a list of commands you can execute to copy the timestamps. I would paste 1-2 of them into bash and make sure they do what you expect (use ls -l to check the timestamps of both files before and after). If the commands do what you expect, re-run the find command but remove the echo and the commands will be executed instead of just listed out like before.

TomOnTime
  • 7,567
  • 6
  • 28
  • 51
  • yes, this solve my problem... i didn test in subfolders, but at least in the same folder i can now make this faster than if i have to do the touch -r in each file. Thank you! – treskilimei Mar 26 '15 at 17:08