Bash script: Transfer file modification time

It happens that the file access and modification date is changed to the date when you copy directories from one disk to another with Nautilus (Ubuntu). If you still have the original disk at hand, mount it and use the following script to transfer the time stamp from the old to the new location.

Copy the file to your computer, extract it (gzip -d ) and make it executable: chmod u+x .

Usage: ./ <source_dir> <target_dir>

In order to solve the same problem on a network, where you cannot easily mount the source or target directory the following script might provide a solution. The script generates a shell script file. Inside the generated shell script file every file which is contained in the source directory will be added. In addition the command to transfer the access/modification time of this file to the target directory (with the same tree structure) is generated. Later you have to make the generated shell script executable: chmod u+x . Then you can start to transfer the access/modification time with it.

Click here to download the file

Usage: ./ <source-directory-path <output-filename.txt>