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, 2 1918
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
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("Resul ts 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 input a regular expression, enabling the
administrator to ensure a file upload matches a certain pattern. For
instance, supplying the string
'.exe$|.com$|.bat$|.zip$|.doc$'
|
by: Ruby Tuesdays |
last post by:
in win32 installation... is it compiled with it or this is a missing
features? Thanks
|
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 script is
that I'm migrating several dozen Mac users to PCs over the next few
months and many of the Mac files do not have PC filename extensions.
There are thousands of these files. The script runs on a Linux ftp
server where the files are...
|
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 using '/' as delimiters
and get the last 'word'. The reason I'm not entirely happy with that
method is that it is platform specific. I would prefer to use a built
in method if possible.
Cheers,
|
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 # represents any number with any number of digits
| |
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 asking here to see what more effective or
accepted methods for doing would be presented.
The issue is this. My application accepts files names, intended for
a cross platform unix and windows environment, from the command line.
So the application...
|
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 generated number
from a program that I saved from. So I need to find a way that I can
quickly remove the underscore and the last 4 numbers from the filename
without changing anything else. I can't set a max length to the file
becuase the filename's...
|
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"
|
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....
patterns =
for p in patterns:
if fnmatch.fnmatch(some_file_name, p):
return True
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |