I need to get the list of files that have been created within a specific period of time in a directory, e.g files created after 19:14 and before 23:11. Each directory contains files belonging to a specific date (24 hours). Should I include the creation time of each file in its name? (like prefix-hh-mm-ss-ms.txt
). These files are meant to be copied from another place to the directory, so I am afraid copying may modify the creation time of file and I should not rely on it. Any advice showing me the best way to achieve what I want to do would be appreciated.
我需要获取在特定时间段内在目录中创建的文件列表,例如在19:14之后和23:11之前创建的文件。每个目录包含属于特定日期(24小时)的文件。我应该在其名称中包含每个文件的创建时间吗? (如prefix-hh-mm-ss-ms.txt)。这些文件是从另一个地方复制到目录,所以我担心复制可能会修改文件的创建时间,我不应该依赖它。任何建议向我展示实现我想做的最佳方式将不胜感激。
1 个解决方案
#1
1
Copying should not "modify" the creation time; since the destination file was actually only created at copying time, isn't it only logical that the creation time of the copied file is the time when the copying occured?
复制不应“修改”创建时间;由于目标文件实际上只是在复制时创建的,所以复制文件的创建时间是复制发生的时间是否合乎逻辑?
The file creation time is however not really available under linux anyway (see the question you linked yourself How to get 'file creation time' in Linux, or https://superuser.com/questions/437663/whats-an-elegant-way-to-copy-the-creation-and-modification-dates-of-a-file-to-a).
然而,文件创建时间在linux下并不真正可用(请参阅您自己链接的问题如何在Linux中获取'文件创建时间',或https://superuser.com/questions/437663/whats-an-elegant-way -to-复制的创造和修饰,日期对的一档至A)。
So you'll have to encode that in some other way anyway. Encoding it in the filename as you suggest sounds like a reasonable way!
因此,无论如何,您必须以其他方式对其进行编码。像你建议的那样将它编码在文件名中听起来像是一种合理的方式!
#1
1
Copying should not "modify" the creation time; since the destination file was actually only created at copying time, isn't it only logical that the creation time of the copied file is the time when the copying occured?
复制不应“修改”创建时间;由于目标文件实际上只是在复制时创建的,所以复制文件的创建时间是复制发生的时间是否合乎逻辑?
The file creation time is however not really available under linux anyway (see the question you linked yourself How to get 'file creation time' in Linux, or https://superuser.com/questions/437663/whats-an-elegant-way-to-copy-the-creation-and-modification-dates-of-a-file-to-a).
然而,文件创建时间在linux下并不真正可用(请参阅您自己链接的问题如何在Linux中获取'文件创建时间',或https://superuser.com/questions/437663/whats-an-elegant-way -to-复制的创造和修饰,日期对的一档至A)。
So you'll have to encode that in some other way anyway. Encoding it in the filename as you suggest sounds like a reasonable way!
因此,无论如何,您必须以其他方式对其进行编码。像你建议的那样将它编码在文件名中听起来像是一种合理的方式!