Russ,
Here is a function that will return the name of a file that has a create date
of today. I can be tweaked to fit your specific needs, like adding error
handling. You will need to add a reference to the Microsoft Scripting Runtime
for it to work.
Regards,
Jeff
Public Function TodaysFile() As String
Dim fso As New FileSystemObject
Dim DirFiles As Files
Dim newFile As File
Dim retVal As String
' Set a default value to return
retVal = "File Not Found"
' Get all of the files in the Folder that contains your files
Set DirFiles = fso.GetFolder("C:\Data").Files
' Loop through all of the files in the dir
For Each newFile In DirFiles
If Format(newFile.DateCreated, "mm/dd/yyyy") = Format(Now(),
"mm/dd/yyyy") Then
' Found todays file set the function to the name
retVal = newFile.Name
' Get out of Dodge
Exit For
End If
Next
' Clean up
Set fso = Nothing
Set DirFiles = Nothing
Set newFile = Nothing
' Return the file name
TodaysFile = retVal
End Function
________________________________
From: [email protected] [[email protected]]
Sent: Tuesday, January 25, 2011 4:49 PM
To: [email protected]
Subject: [talkbws] Finding a File In A Directory
Is there a way for a script to spot the one file that was created today in a
directory full of files?
Thanks,
Russell Duckworth
Financial Systems Analyst
Arkansas Children's Hospital
1 Children's Way, MS 400
Little Rock, AR 72202
Phone: (501) 364-1040
Fax: (501) 364-6859
________________________________
The information contained in this message may be privileged and confidential
and protected from disclosure. If the reader of this message is not the
intended recipient, or an employee or agent responsible for delivering this
message to the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please notify
us immediately by replying to the message and deleting it from your computer.
Thank you.
--- To post a message to this list, send mail to: [email protected] You are
currently subscribed as: [email protected] Unsubscribe in the
customer center on our website:
http://www.bostonworkstation.com/customer_center/virtual_user_group_talk.aspx
________________________________
Portage Health Disclaimer - The information transmitted in this email is
intended only for the person or entity to which it is addressed and may contain
confidential and/or privileged material, including protected health
information. If you are not the intended recipient, you are hereby notified
that any review, retransmission, dissemination, distribution, or copying of
this message is strictly prohibited. If you have received this communication in
error, please destroy and delete this message from any computer and contact us
immediately by return email.
--- To post a message to this list, send mail to: [email protected] You are
currently subscribed as: [email protected] Unsubscribe in the
customer center on our website:
http://www.bostonworkstation.com/customer_center/virtual_user_group_talk.aspx