how to keep date created when copying files
how to copy file and preserve its date stamp?
Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
- cretsiah
- Level 3
- Posts: 162
- Joined: Wed Jul 22, 2020 5:44 am
how to copy file and preserve its date stamp?
ok so i need to copy a file,
the problem is standard/basic copy wont work. for the program to keep working i need to preserve the initial setup date..
ie file creation date 11/10/2020; file last access today
if i try to copy the file i get
file modified today; last access today...
as soon as you try to use the copied file, program fails
this is a bug for AT Launcher and new Minecraft updates...
it completely renders the mods inoperable
i need to reinstall the computer with a fresh install of system due to changes i need to make to the system.
system changes include changing from MBR setup to GPT
- donalduck
- Level 4
- Posts: 210
- Joined: Mon Oct 07, 2013 1:43 pm
- Location: there
Re: how to copy file and preserve its date stamp?
Post by donalduck »
hi,
I don't know if your issue is indeed file's date(s) attribute(s),
but to preserve file's date, first make sure the program is not running e.g files are not already opened/being used, then either use:
excerpt from man page
--preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all
-p same as --preserve=mode,ownership,timestamps
either use touch command, for example
-a change only the access time
-m change only the modification time
-t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time--time=WORD
change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m--help display this help and exit
other useful utility is
, to check file's attributes.
-
GS3
- Level 8
- Posts: 2385
- Joined: Fri Jan 06, 2017 7:51 am
Re: how to copy file and preserve its date stamp?
Post by GS3 »
This is the way I understand it:
Created timestamp is when the OS created this instance of the file in the file system and the OS will not allow it to be changed. This timestamp can be later than "modified" and there is no contradiction. If the file was copied after it was modified then the copy was created after the contents was last modified.
Last Modified is what it says, when the file was last modified. When I copy a file the last modified timestamp does not change.
Accessed is what it says, when the file was last accessed.
Modified and accessed timestamps can be edited (by using Double Commander for instance). Created I do not know how to modify it but I do not think any program would or should care. A program might care about when it was modified because, in a way, it is like a version.
If a program somehow checks and validates the file created timestamp I believe this might be a sort of copy-prevention measure so the program needs to be properly installed and cannot be just copied.
Please do not use animated GIFs in avatars because many of us find them distracting and obnoxious. Thank you.
- t42
- Level 7
- Posts: 1563
- Joined: Mon Jan 20, 2014 6:48 pm
Re: how to copy file and preserve its date stamp?
Post by t42 »
cretsiah wrote: ↑
Wed Feb 10, 2021 10:19 pm
how to copy file and preserve its date stamp?
If the modification date and the last access date is enough for you during cp operation, then use
cp -p original /dest_path/
sample of stat some_file:
origin
Code: Select all
Access: 2020-10-30 00:34:54.000000000 +0100 Modify: 2018-03-23 10:03:06.000000000 +0100 Change: 2021-01-13 13:53:36.753419491 +0100 copy
Code: Select all
Access: 2020-10-30 00:34:54.000000000 +0100 Modify: 2018-03-23 10:03:06.000000000 +0100 Change: 2021-02-11 19:10:59.834243731 +0100 It's true what Hoser Rob said about the creation time that there is no simple solution ... in fact you can get a file creation time with newer kernels but it involves some weightlifting get file status
Edit: somehow missed donalduck's comment above, sorry...
Last edited by t42 on Thu Feb 11, 2021 1:40 pm, edited 1 time in total.
-=t42=-
-
revmacian
- Level 4
- Posts: 413
- Joined: Wed May 27, 2020 1:50 pm
Re: how to copy file and preserve its date stamp?
Post by revmacian »
GS3 wrote: ↑
Thu Feb 11, 2021 12:32 pm
This is the way I understand it:Created timestamp is when the OS created this instance of the file in the file system and the OS will not allow it to be changed. This timestamp can be later than "modified" and there is no contradiction. If the file was copied after it was modified then the copy was created after the contents was last modified.
Last Modified is what it says, when the file was last modified. When I copy a file the last modified timestamp does not change.
Accessed is what it says, when the file was last accessed.
Modified and accessed timestamps can be edited (by using Double Commander for instance). Created I do not know how to modify it but I do not think any program would or should care. A program might care about when it was modified because, in a way, it is like a version.
If a program somehow checks and validates the file created timestamp I believe this might be a sort of copy-prevention measure so the program needs to be properly installed and cannot be just copied.
I don't think file creation dates should be modified. Consider this; you have a file in ~/Documents that was created a month ago. Now you want to copy that file to the Desktop. The issue is that this copy of the file didn't exist in ~/Desktop a month ago so last month's creation date cannot be used as it would present a file falsification issue. Perhaps this is why creation date is difficult to falsify? If you're changing a fact, then that would be a type of falsifying data, would it not?
Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.
US Navy, NEC HM8404
- linux-rox
- Level 6
- Posts: 1200
- Joined: Sun Jul 19, 2020 9:17 pm
Re: how to copy file and preserve its date stamp?
Post by linux-rox »
cretsiah wrote: ↑
Wed Feb 10, 2021 10:19 pm
... file creation date 11/10/2020
Are you sure creation date is the problem? More likely it's modification and/or access dates, for which others have supplied the solution. If by some mad chance you indeed need to control creation date, the usual way would be by manipulating the system clock. First, disable internet sync of the clock, then set manually to the desired date (and time, if important). Copy files. Re-enable internet sync of clock.
-
GS3
- Level 8
- Posts: 2385
- Joined: Fri Jan 06, 2017 7:51 am
Re: how to copy file and preserve its date stamp?
Post by GS3 »
revmacian wrote: ↑
Thu Feb 11, 2021 1:30 pm
I don't think file creation dates should be modified. Consider this; you have a file in ~/Documents that was created a month ago. Now you want to copy that file to the Desktop. The issue is that this copy of the file didn't exist in ~/Desktop a month ago so last month's creation date cannot be used as it would present a file falsification issue. Perhaps this is why creation date is difficult to falsify? If you're changing a fact, then that would be a type of falsifying data, would it not?
I do not know enough about Linux and Ext4 to have any useful insight regarding whether changing the creation timestamp might cause problems (although I don't see how). Granted Windows and NTFS metadata work differently but there I can (and I do) edit all three without any problem.
Please do not use animated GIFs in avatars because many of us find them distracting and obnoxious. Thank you.
-
GS3
- Level 8
- Posts: 2385
- Joined: Fri Jan 06, 2017 7:51 am
Re: how to copy file and preserve its date stamp?
Post by GS3 »
linux-rox wrote: ↑
Thu Feb 11, 2021 2:04 pm
Are you sure creation date is the problem? More likely it's modification and/or access dates, for which others have supplied the solution.
I cannot see how the last accessed date could be a problem because that is going to change.
I can see how a program might check the file modification timestamp to ensure it is the right version.
And I can see how a program installer might somewhere keep the file creation timestamp so that merely copying the files would not work and they would have to be properly installed with the installer. I have seen many programs that needed to be installed with an installer and would not work if merely copied. Often they required the installation CD to be present.
linux-rox wrote: ↑
Thu Feb 11, 2021 2:04 pm
If by some mad chance you indeed need to control creation date, the usual way would be by manipulating the system clock. First, disable internet sync of the clock, then set manually to the desired date (and time, if important). Copy files. Re-enable internet sync of clock.
Yes, the old trick. Many years ago a version of Zonealarm screwed up and would not work past a certain date and the only way to uninstall it was to roll back the clock to an earlier time.
Please do not use animated GIFs in avatars because many of us find them distracting and obnoxious. Thank you.
how to keep date created when copying files
Source: https://forums.linuxmint.com/viewtopic.php?t=342422
Posted by: wrightcoma1941.blogspot.com

0 Response to "how to keep date created when copying files"
Post a Comment