Re: fnmatch on filename (without specific extension)

2006-04-09 Thread kepioo
i agree with you, it is better to find by ourself.

i managed to do it, but i left the code at work. i used the re module ,
using a re.match("Results Log") and a re.search(date) with a function
to find the date og the day with the appropriate format.

Is it ok to use re for file names? or fnmatch is more efficient?

thanks anyway!

Nassim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fnmatch on filename (without specific extension)

2006-04-09 Thread Peter Hansen
kepioo wrote:
> I have some files in a directory :
> Results Log, 11;21AM, Apr 09 2006.txt
> Results Log, 11;21AM, Apr 08 2006.txt
> Results Log, 03;59AM, Apr 07 2006.txt
> otherfile1.txt
> otherfile2.txt
> 
> I'd like to copy all the Results Log file, whatever the hour but with a
> specific day. For instance, today ( 9th april), the script should copy
> the first file : Results Log, 11;21AM, Apr 09 2006.txt

So you need to be able to match on the relevant parts of the file name, 
which appear to be "Results Log" at the start of the name, and today's 
date formatted appropriately for the end, plus ".txt" as an extension. 
You seem to know about the existence of the fnmatch module, so what 
exactly are you having difficulty with?  Please post some code showing 
what you've been able to do so far.  (I could also just hand you an 
answer, but this isn't a difficult problem and you wouldn't learn as 
much as if you have to walk through it yourself.  Of course, inevitably 
somebody will post a complete answer anyway...)

-Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


fnmatch on filename (without specific extension)

2006-04-08 Thread kepioo
Hi,


I have some files in a directory :
Results Log, 11;21AM, Apr 09 2006.txt
Results Log, 11;21AM, Apr 08 2006.txt
Results Log, 03;59AM, Apr 07 2006.txt
otherfile1.txt
otherfile2.txt
...



I'd like to copy all the Results Log file, whatever the hour but with a
specific day. For instance, today ( 9th april), the script should copy
the first file : Results Log, 11;21AM, Apr 09 2006.txt


Any idea, help?

Regards,

-- 
http://mail.python.org/mailman/listinfo/python-list