MTM2.com

A forum for mtm2 discussion
FAQ :: Search :: Members :: Groups :: Register
Login
It is currently Mon Nov 25, 2024 1:00 am



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ASP file dates
PostPosted: Sun Oct 26, 2003 1:39 pm 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
The goal is to list files according to date. In perl, it would look something like this:

Code:
$dir = '/home/blah/blah';

opendir (DIR, $dir) || die "Can't opendir $dir: $!";
 @ondisk = sort readdir (DIR);
closedir (DIR);

foreach $file (@ondisk) {
  $date = (stat "$dir/$file")[10];
  if ($date [is after 01/10/03]) {
    print "$file";
  }
}


Can that be done using ASP and how might you go about it? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 2:02 am 
Glow Ball
User avatar

Joined: Tue Feb 02, 1999 7:00 pm
Posts: 23
Code:
<%

'Declare our FileSystemObject variable
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Declare our folder variable
Dim objFolder

'Now, what is our web's root folder?
Dim strRootFolder
strRootFolder = "C:\Path\Blah\Blah"

'set our folder object to the web root folder
Set objFolder = objFSO.GetFolder(strRootFolder)

 'Declare a file object and a couple variables
Dim objFile
Dim Mydate, ArbDate
Dim iDiff, MyCount
ArbDate = DateSerial(1970, 1, 1)
MyCount = 0

'Now, use a for each...next to loop through the Files collection

For Each objFile in objFolder.Files
  Mydate = FormatDateTime(objFile.DateLastModified, vbShortDate)
  iDiff = DateDiff("m", ArbDate, objFile.DateLastModified)
  if iDiff < 24 And iDiff > -1 then
   Response.Write objFile.Name & " ( " & Mydate & " ) " &iDiff& " <BR>"
   MyCount = MyCount + 1
  end if
Next

   Response.Write MyCount

%>




Sources:

Iterating through the FileSystemObject Collections
http://www.4guysfromrolla.com/webtech/f ... faq5.shtml

Using the FileSystemObject for Web Site Maintenance
http://www.4guysfromrolla.com/webtech/091499-1.shtml

FileSystemObject
http://www.4guysfromrolla.com/aspfaqs/S ... ?FAQID=118

Dates and Times
http://www.4guysfromrolla.com/aspfaqs/S ... p?FAQID=18
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=183

Strings
http://www.4guysfromrolla.com/aspfaqs/S ... p?FAQID=17


I like talking to myself :roll:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 6:45 am 
Member
User avatar

Joined: Thu Apr 19, 2001 2:01 pm
Posts: 695
Location: USA and Proud of it.
lol - i looked at the answer - then i was like - wait who was that - then i was like who asked the question then? - oh lol - then i was like i should comment that he's talking to himself, then i'm like - oh - when i saw the bottom of your post.

_________________
Keep on MTMing,
CH_2005
<a href="http://ch.mtm2.com/">Visit my site</a>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group