On Wed, Jun 25, 2008 at 2:21 PM, chase pettet <[EMAIL PROTECTED]> wrote:
> import os, time, sys
> current = time.time()
> os.chdir("c:\BACKUPS\DEV1")
>
> for f in os.listdir('.'):
> modtime = os.path.getmtime('.')
> if modtime < current - 30 * 86400:
> os.remove(f)
>
I'm not in a place w
"Lie Ryan" <[EMAIL PROTECTED]> wrote
You should do this instead:
r'C:\nice\try'
OR
'C:\\nice\\try'
the first way is called raw string, the backslash lose its meaning
the second way is by escaping the backslash.
Or just use forward slashes which work on *nix or windows...
'C:/nice/try'
HTH
- Message from [EMAIL PROTECTED] -
Date: Thu, 26 Jun 2008 04:53:14 +0700
From: Lie Ryan <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: [Tutor] Removing files based upon time stamps
To: tutor@python.org
I'm not sure what caused your p
On Thu, Jun 26, 2008 at 04:53:14AM +0700, Lie Ryan wrote:
> I'm not sure what caused your problem, but...
Look at where you're checking the file time. You're
not checking the file itself, but '.' (the time of the
current directory).
--
Steve Willoughby| Using billion-dollar satellites
[EMA
You might also want to consider using the path walk
facility in Python's standard lib as well, so you
can recurse into subdirectories doing this (if that
is helpful)
--
Steve Willoughby| Using billion-dollar satellites
[EMAIL PROTECTED] | to hunt for Tupperware.
__
I'm not sure what caused your problem, but...
> os.chdir("c:\BACKUPS\DEV1")
This is a no-no. What if you have a path like this:
'C:\nice\try'
what do you think would python be doing?
It would parse \n as newline and \t as tab
You should do this instead:
r'C:\nice\try'
OR
'C:\\nice\\try'
the
I'm trying to create a basic script that will remove old backup files (more
than 30 days) from a directory based upon timestamp. The system it will run
on is Windows XP. I created this and ran it on one box and it seemed to
work fine, when I ported it to the actual box it needs to run on it is no