how to filter files by creation date

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Nov 6 03:00:40 EST 2007


On Mon, 05 Nov 2007 23:33:16 -0800, awel wrote:

> I am trying to to make a script to move all the files that has been
> created at today's to another folder but my problem is the date format
> that I receive from the 'os.stat  [stat.ST_CTIME]' is different from
> the one that I receive from the 'datetime.date.today()'.

Build a `datetime.date` object from the timestamp you get from the stat
call:

In [438]: !touch test.py

In [439]: datetime.date.fromtimestamp(os.stat('/home/bj/test.py').st_ctime)
Out[439]: datetime.date(2007, 11, 6)

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list