<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hi.<BR> I wrote a python script that goes through a specified directory and returns a list of all the files that haven't been modified since a certain date. I was hoping to be able to then continue with the program to bring up dos, and zip, then move the files (to my external hard drive). I have Windows XP. I don't know if it's okay to ask about Dos in python mailing list, so I hope it's alright. Here is my program, I don't know if there are any formatting rules for posting programs, so I hope this will sufice.<BR><BR>import os, sys, time<BR>def earlierThan (path, year, exclude=[]):<BR> all = []<BR> walk = <FONT face="">os.walk</FONT>(path)<BR> for root, dirs, files in walk:<BR> for i in files:<BR> try:<BR> if (time.localtime(os.path.getmtime(root + "\\" + i))[0] < year<BR> and doesNotHave(exclude, root)) :<BR> all.append(root + "\\" + i)<BR> except OSError: #I think that I might need a more specific error message, as this one would handle something<BR>
#That's not necessarily a broken file name. (I got one of them when I ran it).<BR> print root + "\\" + i + " was not included in the list"<BR> return all<BR>
<BR>def doesNotHave(exclude, root):<BR> for x in exclude:<BR> if root.startswith(x) > -1:<BR> return False<BR> return True<BR><BR>I've had little experience with dos. I believe I should use the COMPACT, and then the MOVE dos <FONT face="">command... Would it go something like this?<BR><BR></FONT>g = earlierThan("G:\My Documents", 2007, ["Music"])<BR>for x in g:<BR>
os.system("COMPACT /F " + x)<BR>
os.sytem("MOVE " + x + " " + "H:\Backup")<BR><BR>Thanks<BR><BR><br /><hr />Need to know the score, the latest news, or you need your HotmailŪ-get your "fix". <a href='http://www.msnmobilefix.com/Default.aspx' target='_new'>Check it out.</a></body>
</html>