I'd like to create a list of all files in a directory that were created
after a certain date. How does one do this? I've used glob.glob to
create a list of all files whose name matches a substring, but I don't
see how I can use it to identify files by their creation date.
Thanks in advance for the assistance.
Thomas Philips 3 10173
ThomasI've used glob.glob to create a list of all files whose name
Thomasmatches a substring, but I don't see how I can use it to
Thomasidentify files by their creation date.
Sumthin' like:
files = [f for f in glob.glob(globp at)
if os.path.getctim e(f) timethreshold]
Define globpat and timethreshold accordingly. You sure you don't mean
modification time? If so, change getctime to getmtime.
Skip
On Tue, 16 Jan 2007 07:44:29 -0600, skip wrote:
ThomasI've used glob.glob to create a list of all files whose name
Thomasmatches a substring, but I don't see how I can use it to
Thomasidentify files by their creation date.
Sumthin' like:
files = [f for f in glob.glob(globp at)
if os.path.getctim e(f) timethreshold]
Define globpat and timethreshold accordingly. You sure you don't mean
modification time? If so, change getctime to getmtime.
help(os.path.ge tctime)
getctime(filena me)
Return the metadata change time of a file, reported by os.stat().
Note that _change_ time != creation time. Also for all files you probably
want os.listdir() instead of glob.
--
James Antill -- ja***@and.org http://www.and.org/and-httpd/ -- $2,000 security guarantee http://www.and.org/vstr/
Thanks a mill - os.path.getctim e(f) is what I needed. Unfortunately, my
attempts to turn the integer it returns into a date have failed.
>>os.path.getct ime(fn) #fn was created today, 1/17/2007
1168955503
I tried to convert this to a date object by typing
>>>datetime.dat e.fromordinal(1 168955503)
Traceback (most recent call last):
File "<pyshell#9 >", line 1, in -toplevel-
datetime.date.f romordinal(1168 955503)
ValueError: year is out of range
How can I do the conversion? I'm trying to identify all files that were
created after YYYY/MM/DD.
For a quick sanity check, I ran
>>datetime.date .today().toordi nal()
732693
which is orders of magnitude smaller than the number returned by
os.path.getctim e(fn).
Thanks in advance for your help
Thomas Philips This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nek |
last post by:
Greetings,
I am running DB2 WSE V8.1, FP5 on W2K.
The problem is not directly related to DB2 but as part of job, I need
to manipulate files coming in from all sources.
Under a main folder, every subfolder signifies data coming from a
different source. The source can further subdivide into more folders.
|
by: Steven Blair |
last post by:
Hi,
I have a trace log file for a system I am writing. If the creation date
is older than 14 days, I have to rename that file (File.Move). The next
time a trace message is required a new file is created
StreamWriter sw = new StreamWriter(path,true);
The problem is, the creation date of this new file has the creation date
of the previous log file :S and not the present date.
|
by: Raed Sawalha |
last post by:
I wondering if it possilble to get the directory files ordered by creation date
string files = System.IO.Directory.GetFiles(strPath,"*.msg")
can I sort the returned file by creation date?
or is there a ready method do the jobthat in .NET
|
by: Amjad |
last post by:
I want to sort files in a specified folder by their creation date and then
display their names (sorted by the creation date) in a textbox for example.
How would you do that?
Dim dir As New DirectoryInfo("C:\myFldr")
Dim myfile As FileInfo
For Each myfile In dir.GetFiles("*.*")
...
Next
|
by: Martin Ho |
last post by:
Two questions:
1.)
I am copying a whole bunch of files from one directory, but I need to
do a if command to copy on those which date of creation is the same
as today's date. How do I do this comparision?
To give you some hint , this is how it could look but this of course
doesn't work, both variables return date with the time signature...I
need to compare only dates between date of creation and local date.
| |
by: Daz |
last post by:
Hi everyone!
This is my first time posting in this group, although I have been
watching it for the past few months and have to say this is possibly
the best group I have seen on Google so far! (That wasn't a
butt-kissing comment, I just believe in giving praise when it's due).
I would like to copy files using globbing, and I am not sure of the
best way to do it. I have tried using system("COPY
"), but It's still not quite what I am...
|
by: Thomas Bauer |
last post by:
Hello,
Call
DeleteFiles bgW_DeleteFilesProcess = new DeleteFiles();
bgW_DeleteFilesProcess.RunAsync( folder, 5, "*.txt", new
RunWorkerCompletedEventHandler( RunWorkerCompleted_DeleteFiles_TXT ) );
I delete all files, which older than 5 days and I use a background
thread.
|
by: Kenneth Porter |
last post by:
Due to a mis-feature in Windows filesystems, I need a globbing function in
C or C++ that can emulate the globbing done by the built-in FindFirstFile
API. The license should allow it to be incorporated into the wxWidgets
framework.
Background:
http://groups.google.com/group/comp.soft-
sys.wxwindows/browse_thread/thread/210dbcbbb9694a79
|
by: aRTx |
last post by:
I have try a couple of time but does not work for me
My files everytime are sortet by NAME.
I want to Sort my files by Date-desc.
Can anyone help me to do it?
The Script
<?
/*
ORIGJINALI
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |