How to sync only timestamps of files?

Is there any r (?) Sync method on Linux timestamps command line only for files with equal content only ?

those. some directory structure was copied without copying timestamps and then changed independently. Now you need to copy the timestamps of equal files only to simplify further synchronization.

+3
source share
2 answers

It seems like the answer to my question is (almost):

rsync -a -c --existing /source/ /destination/

This will copy files that are different from each other, and as I understand it, quietly synchronize timestamps of equal files.

As usual, try using the key -n(or --dry-run).

ADDED:

, . , script, , :

#!/bin/bash

# Ensure that there is a trailing '/'.
SRC="$(dirname $1)/$(basename $1)/"
DST="$(dirname $2)/$(basename $2)/"

if ! [[ -d "$SRC" ]] || ! [[ -d "$DST" ]]; then
  echo "Usage:"
  echo "  $(basename $0) src/dir dst/dir"
  exit 1
fi

diff -rqs "$SRC" "$DST" | grep -Po "(?<=^Files $SRC).*(?= and $DST.* are identical$)" | rsync -tv --files-from=- "$SRC" "$DST"
+1

:

rsync -vrtpi --size-only /media/myname/Dropbox/ /home/myname/Dropbox

-t , , --size-only .

"/" Dropbox.

-c, --checksum .

, , dry-run, , :

rsync -vrtpi --size-only --dry-run /media/myname/Dropbox/ /home/myname/Dropbox > foo.txt
0

All Articles