I'm not much of an ASP programmer. I'm working on a very small app to build a basic web page with url links to some pdfs. I have the main functionality done and working but the problem is sorting. I need to sort the list which I'm not sure how to do. To make it worse, I need to sort the files by the month and year for each document, which is part of the file name.
Can anyone show me how to sort this?
Here's what I have so far:
<% function MapURL(path)
dim rootPath, url
'Convert a physical file path to a URL for hypertext links.
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function %>
<%
Dim path1, item
path1 = "/letters/"
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder("E:\inetpub\
Set fc = folder.files
for each item in folder.SubFolders
ListFolderContents(item.Path)
next
for each item in folder.Files
url = MapURL(item.path)
Response.Write("<li><a href=""" & url & """>" _
& item.Name & "</a>" _
& "</li>" & vbCrLf)
next
%>
This give me a page of urls like this:
XYZ APRIL 2006 LETTER.pdf
XYZ AUGUST 2006 LETTER.pdf
XYZ DECEMBER 2006 LETTER.pdf
XYZ FEBRUARY 2006 LETTER.pdf
XYZ DECEMBER 2007 LETTER.pdf
XYZ AUGUST 2007 LETTER.pdf
The files are generally in this form. Any suggestions, preferrably examples on how to handle this so the output would be:
XYZ AUGUST 2007 LETTER.pdf
XYZ DECEMBER 2007 LETTER.pdf
XYZ FEBRUARY 2006 LETTER.pdf
XYZ APRIL 2006 LETTER.pdf
XYZ AUGUST 2006 LETTER.pdf
XYZ DECEMBER 2006 LETTER.pdf
Any help is appreciated!
JAmes
Can anyone show me how to sort this?
Here's what I have so far:
<% function MapURL(path)
dim rootPath, url
'Convert a physical file path to a URL for hypertext links.
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function %>
<%
Dim path1, item
path1 = "/letters/"
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder("E:\inetpub\
Set fc = folder.files
for each item in folder.SubFolders
ListFolderContents(item.Path)
next
for each item in folder.Files
url = MapURL(item.path)
Response.Write("<li><a href=""" & url & """>" _
& item.Name & "</a>" _
& "</li>" & vbCrLf)
next
%>
This give me a page of urls like this:
XYZ APRIL 2006 LETTER.pdf
XYZ AUGUST 2006 LETTER.pdf
XYZ DECEMBER 2006 LETTER.pdf
XYZ FEBRUARY 2006 LETTER.pdf
XYZ DECEMBER 2007 LETTER.pdf
XYZ AUGUST 2007 LETTER.pdf
The files are generally in this form. Any suggestions, preferrably examples on how to handle this so the output would be:
XYZ AUGUST 2007 LETTER.pdf
XYZ DECEMBER 2007 LETTER.pdf
XYZ FEBRUARY 2006 LETTER.pdf
XYZ APRIL 2006 LETTER.pdf
XYZ AUGUST 2006 LETTER.pdf
XYZ DECEMBER 2006 LETTER.pdf
Any help is appreciated!
JAmes