Find Files in a Folder Between 2 Dates

Gregory Plantaine gamersunit at gmail.com
Thu Dec 11 19:35:33 EST 2008


On Dec 11, 11:02 am, Gregory Plantaine <gamersu... at gmail.com> wrote:
> On Dec 5, 3:14 pm, John Machin <sjmac... at lexicon.net> wrote:
>
>
>
>
>
> > On Dec 6, 9:41 am, GregoryPlantaine<gamersu... at gmail.com> wrote:
>
> > > That worked perfectly!
>
> > > Thanks Tim!
>
> > > Since we can print the files, does that mean the list of files is in a
> > > tuple, or something?  Would there be a way to further split up the
> > > file names?
>
> > > For example, now that the files are processed into the list, we want
> > > to look through that list to find different filetypes.
>
> > > files
>
> > > C:\Folder\File_200812051439.111
> > > C:\Folder\File_200812051539.222
>
> > *DANGER* It looks like you are interested in the timestamps that are
> > embedded in the names of the files. Tim's code assumes [reasonably
> > given that your problem description was ambiguous and had no examples
> > of good and bad results] that you are interested in the last
> > modification time of the file. You may say "same thing". Yes, same
> > thing, until somebody sucks a file into a text editor, messes with it,
> > and saves it again. No, Murphy's Law has not been repealed.
>
> > > Can we split up .111 files?
>
> > > Actually, where would I look something like this up?
>
> > In the Library Reference Manual ... there are all sorts of goodies in
> > the os and os.path modules e.g. like those used by Tim; make sure you
> > read the docs on the methods Tim used so that you understand what's
> > happening.
>
> > HTH,
> > John
>
> Thanks for the advice John!
>
> I was going though the Manual, but I'm having some trouble figuring
> out how to iterate through each line.
>
> So from the same example, we've already created a list called "lists".
> Now how do I iterate through each line?
>
> For eachline in lists
>     Find all .111 files.- Hide quoted text -
>
> - Show quoted text -

Ok, I figured it out. Actually more simple than I thought:

for eachfile in files:
	if eachfile.endswith(".111"):
		print eachfile

Another somewhat related question, instead of defining the firstdate,
how would we do this?

firstdate = secondate - 7 days



More information about the Python-list mailing list