ASP/VB how to display files in a folder with todays date

Hi All,

i am trying to display a total number of .txt files from a folder which contain todays Date.

could someone point me in the direction of how to do this?

thanks,
Arran PumphreyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
how's the file name looks like?

you can try use FileSystemObject to do this

For example:

Dim objFSO, objFile, objFolder

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath("/t/my_folder"))

For Each objFile in objFolder.Files
     Response.Write objFile.Name & "<br>"
     'so here you can put in your comparing logic against the file name (objFile.Nam) that contained today's date.
Next
Set objFolder = Nothing
Set objFSO = Nothing

Open in new window


Ref:
Getting the list of files inside a directory by using FileSystemObject in ASP
http://www.plus2net.com/asp-tutorial/file-list.php

ASP Files Collection
http://www.w3schools.com/asp/coll_files.asp
0
Arran PumphreyAuthor Commented:
Hi,

i am currently using
  <%
	Dim fso, folder, files, x
fso = server.createObject("Scripting.FileSystemObject")
folder = fso.GetFolder("c:\inetpub\wwwroot\Incoming2\")
files = folder.Files

Response.write (files.count)

fso = Nothing
%>

Open in new window


however can't get it to only show todays files they are all .txt???
0
Ryan ChongCommented:
yes, so you gonna tell us how's your files look like? examples?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Arran PumphreyAuthor Commented:
they are all just text files with a name in them.

all i am trying to do, is show a total number of files on a page that have todays date

please see this link: This Link
0
Ryan ChongCommented:
>>all i am trying to do, is show a total number of files on a page that have todays date
I assume you mean the file's modified date? if yes then try this:

  <%
      Dim fso, folder, files, x
fso = server.createObject("Scripting.FileSystemObject")
folder = fso.GetFolder("c:\inetpub\wwwroot\Incoming2\")
cnt = 0

For Each objFile in folder.Files

   if  year(objFile.DateLastModified) = year(now()) and month(objFile.DateLastModified) = month(now()) and day(objFile.DateLastModified) = day(now()) and lcase(right(objFile.Name, 4)) = ".txt" then

     Response.Write objFile.Name & "<br>"
 cnt = cnt + 1
     end if

Next

Response.write ("cnt  = " & cnt)

fso = Nothing
%>
0
Arran PumphreyAuthor Commented:
didn't work :(

please see attached YSOD

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: BC30205: End of statement expected.

Source Error:


Line 53:    if  year(objFile.DateLastModified) = year(now()) and month(objFile.DateLastModified) = month(now()) and day(objFile.DateLastModified) = day(now()) and lcase(right(objFile.Name, 4)) = ".txt" then
Line 54: 
Line 55:      Response.Write (objFile.Name) & "<br>"
Line 56:  cnt = cnt + 1
Line 57:      end if

Open in new window

0
Ryan ChongCommented:
Line 53:    if  year(objFile.DateLastModified) = year(now()) and month(objFile.DateLastModified) = month(now()) and day(objFile.DateLastModified) = day(now()) and lcase(right(objFile.Name, 4)) = ".txt" then

looks ok for me. Did you miss out some "end if" somewhere else? before or after line 53?
0
Ryan ChongCommented:
minor changes to the scripts I posted and tested working:

 <%
      Dim fso, folder, files, x
set fso = server.createObject("Scripting.FileSystemObject")
set folder = fso.GetFolder("c:\inetpub\wwwroot\Incoming2\")
cnt = 0

For Each objFile in folder.Files

   if  year(objFile.DateLastModified) = year(now()) and month(objFile.DateLastModified) = month(now()) and day(objFile.DateLastModified) = day(now()) and lcase(right(objFile.Name, 4)) = ".txt" then

     Response.Write objFile.Name & "<br>"
 cnt = cnt + 1
     end if

Next

Response.write ("cnt  = " & cnt)

set fso = Nothing
%>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.