%
Dim fso, f1
Dim year
dim month
dim day
dim hour
dim minute
dim meridan
strFilePath = Server.MapPath("/webcams/epsilon/hugesize.jpg")
'Set fso = Server.CreateObject("Scripting.FileSystemObject")
'Set f1 = fso.GetFile(strFilePath)
' Change the DIRECTORY to point to any virtual directory of your choice.
CONST DIRECTORY = "/webcams/epsilon" ' relative path in virtual directories
' Specify one of these constants for "sortBy"...
CONST FILE_NAME = 0
CONST FILE_EXT = 1
CONST FILE_TYPE = 2
CONST FILE_SIZE = 3
CONST FILE_CREATED = 4
CONST FILE_MODIFIED = 5
CONST FILE_ACCESSED = 6
sortBy=5
path = Server.MapPath( DIRECTORY )
Set fso = CreateObject("Scripting.FileSystemObject")
Set theCurrentFolder = fso.GetFolder( path )
Set curFiles = theCurrentFolder.Files
'
' And now a loop for the files
'
Dim theFiles( )
ReDim theFiles( 1500 ) ' arbitrary size!
currentSlot = -1 ' start before first slot
' We collect all the info about each file and put it into one
' "slot" in our "theFiles" array.
'
For Each fileItem in curFiles
fname = fileItem.Name
fext = InStrRev( fname, "." )
If fext < 1 Then fext = "" Else fext = Mid(fname,fext+1)
ftype = 0'fileItem.Type
fsize = fileItem.Size
fcreate = fileItem.DateCreated
fmod = fileItem.DateLastModified
faccess = fileItem.DateLastAccessed
currentSlot = currentSlot + 1
If currentSlot > UBound( theFiles ) Then
ReDim Preserve theFiles( currentSlot + 99 )
End If
' note that what we put here is an array!
theFiles(currentSlot) = Array(fname,fext,ftype,fsize,fcreate,fmod,faccess)
Next
'
' files are now in the array...
'
' As noted, it is actually an ARRAY *OF* ARRAYS. Which makes
' picking the column we will sort on easier!
'
' ...size and sort it...
fileCount = currentSlot ' actually, count is 1 more, since we start at 0
ReDim Preserve theFiles( currentSlot ) ' really not necessary...just neater!
' First, determine which "kind" of sort we are doing.
' (VarType=8 means "string")
'
If VarType( theFiles( 0 )( sortBy ) ) = 8 Then
If reverse Then kind = 1 Else kind = 2 ' sorting strings...
Else
If reverse Then kind = 3 Else kind = 4 ' non-strings (numbers, dates)
End If
'
' A simple bubble sort for now...easier to follow the code...
'
For i = fileCount TO 0 Step -1
minmax = theFiles( 0 )( sortBy )
minmaxSlot = 0
For j = 1 To i
Select Case kind ' which kind of sort are we doing?
' after the "is bigger/smaller" test (as appropriate),
' mark will be true if we need to "remember" this slot...
Case 1 ' string, reverse...we do case INsensitive!
mark = (strComp( theFiles(j)(sortBy), minmax, vbTextCompare ) < 0)
Case 2 ' string, forward...we do case INsensitive!
mark = (strComp( theFiles(j)(sortBy), minmax, vbTextCompare ) > 0)
Case 3 ' non-string, reverse ...
mark = (theFiles( j )( sortBy ) < minmax)
Case 4 ' non-string, forward ...
mark = (theFiles( j )( sortBy ) > minmax)
End Select
' so is the current slot bigger/smaller than the remembered one?
If mark Then
' yep, so remember this one instead!
minmax = theFiles( j )( sortBy )
minmaxSlot = j
End If
Next
' is the last slot the min (or max), as it should be?
If minmaxSlot <> i Then
' nope...so do the needed swap...
temp = theFiles( minmaxSlot )
theFiles( minmaxSlot ) = theFiles( i )
theFiles( i ) = temp
End If
Next
' Ta-da! The array is sorted!
'
for i=ubound(theFiles) to 0 step -1
if len(theFiles(i)(0))=20 then
' response.Write(theFiles(i)(0) & " - " & theFiles(i)(5) & "
")
year=mid(theFiles(i)(0),5,4)
month=mid(theFiles(i)(0),9,2)
day=mid(theFiles(i)(0),11,2)
hour=mid(theFiles(i)(0),13,2)
minute=mid(theFiles(i)(0),15,2)
' response.Write("Year=" & year & "
")
' response.Write("Month=" & month & "
")
' response.Write("Day=" & day & "
")
' response.Write("Hour=" & hour & "
")
' response.Write("Minute=" & minute & "
")
if Cint(hour) > 12 Then
hour=hour-12
meridan="PM"
else
meridan="AM"
end if
exit for
end if
next
%>
|
|
|
|
|
|
SIZE 200,000 Square Feet LOCATION SWC of 635/Belt Line Rd. Regent Blvd. Irving, Texas DESCRIPTION BTS Corporate Office SPECIAL ATTRIBUTES Raised Access Flooring LEED Certified Project Highly Efficient Floorplates High-Density Parking Plug and Play Design Underfloor HVAC (Reduced OE) ARCHITECT Forum Studio - Shell Gensler - Interiors CONSTRUCTION START January 2006 SCHEDULED COMPLETION December 2006 |
|
|
|
|