Hi,
I need to get a list of all files in a directory sorted by their
date/time of creation.
Please help.
···
--
Posted via http://www.ruby-forum.com/.
Hi,
I need to get a list of all files in a directory sorted by their
date/time of creation.
Please help.
--
Posted via http://www.ruby-forum.com/.
I need to get a list of all files in a directory sorted by their
date/time of creation.
Please help.
Unix like systems don't store file creation info[1]. For last
modified, or access time, see the documentation for File.
--
Anurag Priyam
http://about.me/yeban/
sort_by it:
Dir.entries(".").sort_by{|c| File.stat(c).ctime}
2011/1/8 Rajarshi Chakravarty <raj_plays@yahoo.com>:
Hi,
I need to get a list of all files in a directory sorted by their
date/time of creation.
Or use a Swatz* Transform which is used by sort_by inherently:
Dir.entries(".").map{|c| [c,File.stat(c).ctime]}.sort{|a,b|
a[1]<=>b[1]}.map{|d| d[0]}
* Swatz is a Perl hacker whose full name is Randal Swatz (hope me
remember that correctly).
2011/1/8 zuerrong <zuerrong@gmail.com>:
2011/1/8 Rajarshi Chakravarty <raj_plays@yahoo.com>:
Hi,
I need to get a list of all files in a directory sorted by their
date/time of creation.sort_by it:
Dir.entries(".").sort_by{|c| File.stat(c).ctime}
Or use a Swatz* Transform which is used by sort_by inherently:
Dir.entries(".").map{|c| [c,File.stat(c).ctime]}.sort{|a,b|
a[1]<=>b[1]}.map{|d| d[0]}* Swatz is a Perl hacker whose full name is Randal Swatz (hope me
remember that correctly).
You mean Randal Schwartz and his Schwartzian transform:
As you said, sort_by implements that already, so it's faster to use it
instead directly.
On Sat, Jan 8, 2011 at 6:45 PM, zuerrong <zuerrong@gmail.com> wrote:
2011/1/8 zuerrong <zuerrong@gmail.com>:
2011/1/8 Rajarshi Chakravarty <raj_plays@yahoo.com>:
Hi,
I need to get a list of all files in a directory sorted by their
date/time of creation.sort_by it:
Dir.entries(".").sort_by{|c| File.stat(c).ctime}
--
Michael Fellinger
CTO, The Rubyists, LLC