Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I just transferred 1.8TB of data from an external hard drive to an internal hard drive using rsync, but I didn't add the "-t" flag, so the "Date Modified" for every file on the internal hard drive is now the date I ran rsync.

Is there a way to copy the dates from the source files to the destination files without having to delete the destination files and run rsync again with the "-t" flag?

share|improve this question
add comment

1 Answer

Touching 'modified' to a file from another reference file can not be done with rsync.

However we can user the touch command to do so.

touch -m -r source/path/file dest/path/file

Above will touch the 'modified' date from the source to the destination file path.

This can further be scripted, e.g. below for all files in a given destination directory provided filenames are identical:

 for i in *; do touch $i -m -r /path/to/source/$i; done
share|improve this answer
    
Thanks Takkat! I'm looking for something that will be recursive through multiple directories. Somebody on another forum posted the following: 'find /home/abcdefg/ -exec touch {} \; The abcdefg directory itself will be included. ' –  user217685 Nov 21 '13 at 6:03
    
Never used find before though. Not entirely sure what the brackets or the final slash do either. –  user217685 Nov 21 '13 at 6:17
    
@user217685: yeah find is better for recursiveness. The {} is a placeholder for the filename found, however after doing a quick test yesterday I did not get desired results on different paths so I posted the loop approach. –  Takkat Nov 21 '13 at 7:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.