473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

fnmatch on filename (without specific extension)

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,

Apr 9 '06 #1
2 1892
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

Apr 9 '06 #2
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

Apr 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Martin Lucas-Smith | last post by:
Is there some way of using ereg to detect when certain filename extensions are supplied and to return false if so, WITHOUT using the ! operator before ereg () ? I have an API that allows as an...
13
by: Ruby Tuesdays | last post by:
in win32 installation... is it compiled with it or this is a missing features? Thanks
1
by: hokiegal99 | last post by:
I've written a small script (with much help from this list) that searches through a directory for files without a PC filename extension like .doc .xls and then adds them. The reason for writing the...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
1
by: Graeme Downes | last post by:
Hi I'm trying to create a regular expression for C using the fnmatch function from the fnmatch.h library. I dont know if you can help, but i need something as follows: #:]# where #...
27
by: gmtonyhoyt | last post by:
I need assistance coming up with a clean way to handle filename extensions with my application. While I can come up with several ways of doing so on my own, I felt perhaps it would be worth...
10
by: Brian Gruber | last post by:
Hi, I'm looking for a way to rename a whole directory of files in short order. The files in the directory have different lengths, however all of them end with _xxxx the x's represent a randomly...
2
by: s99999999s2003 | last post by:
hi i have script like this: from fnmatch import fnmatch from glob import glob ..... .... f = r = "d:\\somepath" pat = "*.bat"
4
by: abcd | last post by:
I am using fnmatch.fnmatch to find some files. The only problem I have is that it only takes one pattern...so if I want to search using multiple patterns I have to do something like.... ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.