Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to preserve files original creation date?

I'm moving files on the server from one directory to another using the file manager. Is there a way to preserve file creation date/time (when it was first added to server)? Someone suggested SSH, but I'm not very familiar with it. Does anyone have some good instructions on this?

like image 346
Kakenx Avatar asked Nov 27 '13 23:11

Kakenx


People also ask

How do I keep files from original date?

Substitute “C:photos” and “D:photos” for your source and destination folders respectively. options ensure that your original 'date modified' attributes are preserved during the copy. The /E option ensures that subfolders are also copied, including any empty folders you may have in the original location.

How do I copy a file without changing the date modified?

cp command provides an option –p for copying the file without changing the mode, ownership and timestamps. ownership, mode and timestamp. $ cp -p num.

How do I organize files by date created?

Click the sort option in the top right of the Files area and select Date from the dropdown. Once you have Date selected, you will see an option to switch between descending and ascending order.

Does copying a file change the date modified?

If you copy a file from C:\fat16 to D:\NTFS, it keeps the same modified date and time but changes the created date and time to the current date and time. If you move a file from C:\fat16 to D:\NTFS, it keeps the same modified date and time and keeps the same created date and time.


1 Answers

Use scp with the -p option.

 -p      Preserves modification times, access times, and modes from the original file. 

Example command copying a file from local to remote server:

scp -p /home/mylocaldata/test.txt remote.example.com:/home/remote_dir 

Note that this will not preserve user and group only permission flags (rwx and such).

like image 86
Tharanga Abeyseela Avatar answered Oct 09 '22 07:10

Tharanga Abeyseela