Hello all: I use simple text files for some of my notes. It would be important to keep the creation times of these files even when they are edited, copied or renamed. How can I achieve this? So far I found when I edit a file its modification time is changed, when I copy or rename a file its creation time is changed to the time of the action (editing, copying, renaming). Thanks, IG ________________________________________________________________ Harry Potter és a Félvér Herceg! Garantált szállítás a megjelenés napján! (február 10. ) Jegyezze elő most! http://www.bookline.hu/control/news?newsid=322&affiliate=frehp6kar1482
Tuesday, 24 January 2006 01:20 samaye, Istvan Gabor alekhiit:
So far I found when I edit a file its modification time is changed, when I copy or rename a file its creation time is changed to the time of the action (editing, copying, renaming).
Both ext3 and reiserfs do not store the creation time of the file. There is apparently little use for this, and you fall in the minority who really misses this. A good idea would be to make it a practice to write the date of creation at the top of every new text file. :) -- Penguin #395953 resides at http://samvit.org subsisting on SUSE Linux 10.0 with KDE 3.5
Both ext3 and reiserfs do not store the creation time of the file. There is apparently little use for this, and you fall in the minority who really misses this.
I was afraid that it's not possible. How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename. Thanks, IG ________________________________________________________________ Harry Potter és a Félvér Herceg! Garantált szállítás a megjelenés napján! (február 10. ) Jegyezze elő most! http://www.bookline.hu/control/news?newsid=322&affiliate=frehp6kar1482
Istvan Gabor wrote:
I was afraid that it's not possible.
How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename.
Another observation is that backup systems keep a record of when files are created and changed! You could either use a daily backup itself, or just the log of what a backup system would have done. Even archiving a daily directory listing would tell you when each file was created. Cheers, Dave
Istvan Gabor wrote:
Both ext3 and reiserfs do not store the creation time of the file. There is apparently little use for this, and you fall in the minority who really misses this.
I was afraid that it's not possible.
How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename.
Something on the lines of "mv file-name.txt file-name`date`.txt. When you enclose a command in a pair of ` (that's the key to the left of the number 1) the results of the command are used. You'd use the date format you need. For example date +%jreturns the day of the year. Man date for details. Once you have a working command, you can include it in an appropriate script to do what you want.
How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename.
Something on the lines of "mv file-name.txt file-name`date`. txt.
When you enclose a command in a pair of ` (that's the key to the left of the number 1) the results of the command are used. You'd use the date format you need. For example date +%jreturns the day of the year.
I think it's not that simple. You have to retrieve the file's ctime or mtime and use that value in the filename. Using `date` command doesn't retrieve the file's mtime or ctime. Maybe some awk or sed command could be used. IG ________________________________________________________________ Harry Potter és a Félvér Herceg! Garantált szállítás a megjelenés napján! (február 10. ) Jegyezze elő most! http://www.bookline.hu/control/news?newsid=322&affiliate=frehp6kar1482
On Tue, 2006-01-24 at 15:02 +0100, Istvan Gabor wrote:
How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename.
Something on the lines of "mv file-name.txt file-name`date`. txt.
When you enclose a command in a pair of ` (that's the key to the left of the number 1) the results of the command are used. You'd use the date format you need. For example date +%jreturns the day of the year.
I think it's not that simple. You have to retrieve the file's ctime or mtime and use that value in the filename. Using `date` command doesn't retrieve the file's mtime or ctime. Maybe some awk or sed command could be used.
Not saying it is the case here, but I can only think of one reason someone does not want the timestamp changed on a modified file is that they are trying to hide something. As I said it may not be the case, but. -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998
Not saying it is the case here, but I can only think of one reason someone does not want the timestamp changed on a modified file is that they are trying to hide something. As I said it may not be the case, but.
It seems you don't understand my problem. I don't care of the modification time, moreover I think that is good changing the modification time when the file content is changed. But I don't like that after this I won't be able to tell anymore when the given file was created. And this is an info that is important to me. It would be good if in addition to atime, ctime and mtime the files had a creation time that would not change when the files are copied, renamed or modified. Lack of this is a negative of linux' filesystems in my opinion. IG ________________________________________________________________ Harry Potter és a Félvér Herceg! Garantált szállítás a megjelenés napján! (február 10. ) Jegyezze elő most! http://www.bookline.hu/control/news?newsid=322&affiliate=frehp6kar1482
On Tuesday, January 24, 2006 @ 8:35 AM, Ken Schneider wrote:
On Tue, 2006-01-24 at 15:02 +0100, Istvan Gabor wrote:
How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename.
Something on the lines of "mv file-name.txt file-name`date`. txt.
When you enclose a command in a pair of ` (that's the key to the left of the number 1) the results of the command are used. You'd use the date format you need. For example date +%jreturns the day of the year.
I think it's not that simple. You have to retrieve the file's ctime or mtime and use that value in the filename. Using `date` command doesn't retrieve the file's mtime or ctime. Maybe some awk or sed command could be used.
Not saying it is the case here, but I can only think of one reason someone does not want the timestamp changed on a modified file is that they are trying to hide something. As I said it may not be the case, but.
-- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998
Ken: It's not that he doesn't want to know the last modification date, he just also wants to preserve the creation date as well. Greg W -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Yo! On Tuesday 24 January 2006 20:58, Greg Wallace wrote:
...
Ken: It's not that he doesn't want to know the last modification date, he just also wants to preserve the creation date as well.
Is this conversation any more moot than the religious one? There is not nor has there ever been a creation time in any Linux or Unix file system. OK. I don't actually know that for a fact, but if there is or ever was such a thing, it was not in a mainstream Unix / Linux file system.
Greg W
RRS
On Tuesday, January 24, 2006 @ 11:17 PM, Randall Schulz wrote: Randall:
Yo!
On Tuesday 24 January 2006 20:58, Greg Wallace wrote:
...
Ken: It's not that he doesn't want to know the last modification date, he just also wants to preserve the creation date as well.
Is this conversation any more moot than the religious one?
I was simply letting Ken know that he seemed to be misinterpreting the original question. The original question was not necessarily about not having the modification date changed but about having a creation date that stayed around (could be a different date).
There is not nor has there ever been a creation time in any Linux or Unix file system.
That's what I had come to understand from earlier discussions on this list about this same topic. I was not questioning that at all. I was just trying to clarify what the original poster was looking for.
OK. I don't actually know that for a fact, but if there is or ever was such a thing, it was not in a mainstream Unix / Linux file system.
Greg W
RRS
Greg W
I'm not sure if I can provide the answer directly, but a Linux (and Unix) file contains 3 different time values: 1. ctime: The time the file's inode was last modified. This can happen if you make a change that affects the size of the file. Note that if you create an additional hard link to a file, ctime will change. In the case of the ln command, ctime and atime will change but not mtime. 2. mtime: The time the file's contents were last modified. See my comment above. 3. atime: The time the file was last accessed (such as read). Note that in Linux and Unix, a file is an entry in the Inode table that contains information about a file. The file directories simply contain file names that point to the inode. This is one feature that makes Unix and Linux different from most other operating systems. You can (and do) have files that have different names. For instance, every directory has at last 2 names: 1. The actual name of the directory, such as /usr 2. Dot (.). This is a hard link to the current directory. 3. DotDot (..). This is a hard link to a parent directory. For instance: /usr contains a number of subdirectories, each having a (..) pointing (as a hard link) to the /usr directory. On my system, /usr has 13 hard links (or 13 different names such as /usr, ., /usr/bin/.., etc. (also note that hard links cannot span file systems, but symbolic links can since a symbolic link is a file containing a name of the file it refers to). It is also possible for a file to exist without a name. This can occur in the case where you delete a file that is in use. Since the rm(1) command does not physically delete a file, the open file remains until the program that has it opened closes it. This occurs often if you try to regain space by deleting a large log file, but the daemon using it is still running. -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
On Tue, 24 Jan 2006 21:16:43 -0800 Randall R Schulz <rschulz@sonic.net> wrote:
Yo!
On Tuesday 24 January 2006 20:58, Greg Wallace wrote:
...
Ken: It's not that he doesn't want to know the last modification date, he just also wants to preserve the creation date as well.
Is this conversation any more moot than the religious one?
There is not nor has there ever been a creation time in any Linux or Unix file system.
OK. I don't actually know that for a fact, but if there is or ever was
such a thing, it was not in a mainstream Unix / Linux file system.
OP, This might be what you want: mv file.conf file.conf.orig; cp file.conf.orig file.conf ("mv" doesn't change the date of the file, but "cp" does, hence the "original" date will be preserved.) hth, ken -- "This world ain't big enough for the both of us," said the big noema to the little noema.
Ken, Istvan, On Wednesday 25 January 2006 11:45, ken wrote:
...
This might be what you want:
mv file.conf file.conf.orig; cp file.conf.orig file.conf
("mv" doesn't change the date of the file, but "cp" does, hence the "original" date will be preserved.)
Mv will change the ctime, since the link count changes transiently during the move. Cp can be told to preserve times. Check the options via --help or the man page.
hth, ken
Randall Schulz
Istvan, On Tuesday 24 January 2006 04:19, Istvan Gabor wrote:
Both ext3 and reiserfs do not store the creation time of the
file. There is
apparently little use for this, and you fall in the minority who
really
misses this.
I was afraid that it's not possible.
How could I rename the files in a batch so that the file names themselves would contain the date? Eg. file-name.txt --> file-name_date.txt I have many files I'd like to rename.
There are two commands (along with some scripting) that allow you to transfer one of the file's three timestamps to its name: stat (1) - display file or file system status date (1) - print or set the system date and time The date command has a large array of formatting options and will allow the date it shows to be supplied on the command line, so you can take the output of the appropriate "stat" invocation and pass it to an invocation of "date" that formats the date in a manner suitable for your file-name-embedded timestamps.
Thanks, IG
Randall Schulz
Istvan, On Monday 23 January 2006 11:50, Istvan Gabor wrote:
Hello all:
I use simple text files for some of my notes. It would be important to keep the creation times of these files even when they are edited, copied or renamed. How can I achieve this?
So far I found when I edit a file its modification time is changed, when I copy or rename a file its creation time is changed to the time of the action (editing, copying, renaming).
It's a common misunderstanding that Unix file systems store a creation time. There is a file metadata attribute called "ctime" but it is not the time of the file's creation, but rather the time that the file's so-called "inode" information (the metadata such as it's size, modes, owners, etc.) was changed.
Thanks, IG
Randall Schulz -- Eat drink and be merry, for tomorrow God might get sick of us.
What about storing the creation time as a part of the filename? -- Viele Grüße ------------------------------------------------------------------------ Michael
participants (10)
-
Dave Howorth
-
Greg Wallace
-
Istvan Gabor
-
James Knott
-
Jerry Feldman
-
ken
-
Ken Schneider
-
Michael Behrens
-
Randall R Schulz
-
Shriramana Sharma