Playing With Python – Notes

Just some notes – I am trying to build a python script to fix the dates on my files. I mistakenly use cp instead of tar to restore my home directory during my upgrade to Leopard. So now I have to go through and patch all of the files modification times from the backup.

It should be a fun exercise in Python. Notes below

walk(p, visit, arg) Calls the function visit with arguments(arg,dirname,names) for each directory recursively in the directory tree rooted at p (including p itself if it’s a dir.) The argument dirname specifies the visited directory, the argument names lists the files in the directory. The visit function may modify names to influence the set of directories visited belowdirname, e.g., to avoid visiting certain parts of the tree

>>> from datetime import datetime
>>> now = datetime.utcnow()
>>> z = datetime.utcfromtimestamp(x)
>>> print z
2007-11-09 21:14:36
>>> print z.year
-t      Change the access and modification times to the specified time.
The argument should be in the form ``[[CC]YY]MMDDhhmm[.SS]''
where each pair of letters represents the following:
CC      The first two digits of the year (the century).
YY      The second two digits of the year.  If ``YY'' is
specified, but ``CC'' is not, a value for ``YY''
between 69 and 99 results in a ``CC'' value of 19.
Otherwise, a ``CC'' value of 20 is used.
MM      The month of the year, from 1 to 12.
DD      the day of the month, from 1 to 31.
hh      The hour of the day, from 0 to 23.
mm      The minute of the hour, from 0 to 59.
SS      The second of the minute, from 0 to 61.