Shell tool

2002-05-12 Thread Adam Getchell
Hello all,   I’ve just started trying to use Python to automate Windows system administration. I wrote my first (long-winded, amateurish) shell-tool to os.path.walk through a directory structure and delete files older than 2 days. (Keeps users from cluttering some temporary storage space)

RE: Shell tool

2002-05-12 Thread Richard Kemp
Looks like you're only deleting files, with the "if not os.path.isdir(path)" line.  But beyond that, I think there's a problem with the order in which os.path.walk will call your lister.  walk() will call lister from top-down, whereas a delete type function like this needs to walk from botto

Re: Shell tool

2002-05-12 Thread Matthew Sherborne
I only skimmed you message, but I couldn't see os.removedirs in it:   >>> help('os.removedirs')Help on function removedirs:   removedirs(name)    removedirs(path) -> None        Super-rmdir; remove a leaf directory and empty all intermediate    ones.  Works like rmdir except that, if the l

Re: Shell tool

2002-05-12 Thread Patricia J. Hawkins
Adam, Richard, Microsoft seems to have changed the email standards again; do you think you could send in plain text? Thanks, I appreciate it. (yes, my email client reads html, but it can't cope with this.) > "AG" == Adam Getchell <[EMAIL PROTECTED]> writes: AG> AG> AG> AG> AG> AG>

Shell tool

2002-05-12 Thread Adam Getchell
Sorry about the HTML mail -- here it is plain text. If I understand the suggestions, to do this properly I should probably be doing a Depth-First Search. Well, interestingly I need to do just this for another tool which constructs a dependency tree based upon file dependencies for a particular co

RE: Shell tool

2002-05-12 Thread Richard Kemp
Why not use Matthew's suggestion of os.removedirs() - sounds like its all that you need. Its not as much fun, but I think that single call will do what your entire script is intending to do. - Rick -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Adam G