Re: How to get a directory list sorted by date?

2016-05-16 Thread Random832
On Sun, May 15, 2016, at 17:52, Chris Angelico wrote: > On Mon, May 16, 2016 at 2:00 AM, Grant Edwards > wrote: > > On 2016-05-15, Michael Selik wrote: > >> On Sun, May 15, 2016, 10:37 AM Grant Edwards > >> wrote: >

Re: How to get a directory list sorted by date?

2016-05-15 Thread Chris Angelico
On Mon, May 16, 2016 at 2:00 AM, Grant Edwards wrote: > On 2016-05-15, Michael Selik wrote: >> On Sun, May 15, 2016, 10:37 AM Grant Edwards >> wrote: >>> On 2016-05-15, Tim Chase

Re: How to get a directory list sorted by date?

2016-05-15 Thread cl
Tim Chase wrote: > On 2016-05-15 14:36, Grant Edwards wrote: > > On 2016-05-15, Tim Chase wrote: > > > unless sorted() returns a lazy sorter, > > > > What's a lazy sorter? > > A hypothetical algorithm that can spool out a sorted

Re: How to get a directory list sorted by date?

2016-05-15 Thread Tim Chase
On 2016-05-15 14:36, Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: > > unless sorted() returns a lazy sorter, > > What's a lazy sorter? A hypothetical algorithm that can spool out a sorted sequence without holding the entire sequence in memory at the same

Re: How to get a directory list sorted by date?

2016-05-15 Thread Grant Edwards
On 2016-05-15, Michael Selik wrote: > On Sun, May 15, 2016, 10:37 AM Grant Edwards > wrote: >> On 2016-05-15, Tim Chase wrote: >>> >>> unless sorted() returns a lazy sorter, >> >> What's a lazy sorter? > > One

Re: How to get a directory list sorted by date?

2016-05-15 Thread Michael Selik
On Sun, May 15, 2016, 10:37 AM Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: > > On 2016-05-15 11:46, Peter Otten wrote: > >> def sorted_dir(folder): > >> def getmtime(name): > >> path = os.path.join(folder, name) >

Re: How to get a directory list sorted by date?

2016-05-15 Thread Joel Goldstick
On Sun, May 15, 2016 at 10:36 AM, Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: >> On 2016-05-15 11:46, Peter Otten wrote: >>> def sorted_dir(folder): >>> def getmtime(name): >>> path = os.path.join(folder, name) >>>

Re: How to get a directory list sorted by date?

2016-05-15 Thread Grant Edwards
On 2016-05-15, Tim Chase wrote: > On 2016-05-15 11:46, Peter Otten wrote: >> def sorted_dir(folder): >> def getmtime(name): >> path = os.path.join(folder, name) >> return os.path.getmtime(path) >> >> return sorted(os.listdir(folder),

Re: How to get a directory list sorted by date?

2016-05-15 Thread Vincent Vande Vyvre
Le 15/05/2016 10:47, c...@isbd.net a écrit : I have a little Python program I wrote myself which copies images from a camera (well, any mounted directory) to my picture archive. The picture archive is simply a directory hierarchy of dates with years at the top, then months, then days. My

Re: How to get a directory list sorted by date?

2016-05-15 Thread Peter Otten
Tim Chase wrote: > On 2016-05-15 11:46, Peter Otten wrote: >> def sorted_dir(folder): >> def getmtime(name): >> path = os.path.join(folder, name) >> return os.path.getmtime(path) >> >> return sorted(os.listdir(folder), key=getmtime, reverse=True) >> >> The same idea will

Re: How to get a directory list sorted by date?

2016-05-15 Thread Chris Angelico
On Sun, May 15, 2016 at 9:15 PM, Tim Chase wrote: > On 2016-05-15 11:46, Peter Otten wrote: >> def sorted_dir(folder): >> def getmtime(name): >> path = os.path.join(folder, name) >> return os.path.getmtime(path) >> >> return

Re: How to get a directory list sorted by date?

2016-05-15 Thread Tim Chase
On 2016-05-15 11:46, Peter Otten wrote: > def sorted_dir(folder): > def getmtime(name): > path = os.path.join(folder, name) > return os.path.getmtime(path) > > return sorted(os.listdir(folder), key=getmtime, reverse=True) > > The same idea will work with pathlib and

Re: How to get a directory list sorted by date?

2016-05-15 Thread Tim Chase
On 2016-05-15 20:48, Steven D'Aprano wrote: > Also, remember that most operating systems provide (at least) three > different times. I'm not sure which one you want, but if I had to > guess, I would probably guess mtime. If I remember correctly: > > atime is usually the last access time; > mtime

Re: How to get a directory list sorted by date?

2016-05-15 Thread Steven D'Aprano
On Sunday 15 May 2016 18:47, c...@isbd.net wrote: > What I want is a list in the order produced by:- > ls --sort=time I'm not sure if this is the best way to do it, but what I would do is sort the directory list by the file's time metadata, which you can access using os.stat. To sort the

Re: How to get a directory list sorted by date?

2016-05-15 Thread Peter Otten
c...@isbd.net wrote: > I have a little Python program I wrote myself which copies images from > a camera (well, any mounted directory) to my picture archive. The > picture archive is simply a directory hierarchy of dates with years at > the top, then months, then days. > > My Python program

How to get a directory list sorted by date?

2016-05-15 Thread cl
I have a little Python program I wrote myself which copies images from a camera (well, any mounted directory) to my picture archive. The picture archive is simply a directory hierarchy of dates with years at the top, then months, then days. My Python program simply extracts the date from the