Codessentials

  • Increase font size
  • Default font size
  • Decrease font size
Home Coding tips Web List files from folder - sorted

List files from folder - sorted

This script shows how to list all files in a server folder. Sort order can be changed by setting sort to 1 or -1.
<html>
<body>

<%
sort = 1
folder = "/my_folder"

set fso = CreateObject("Scripting.fileSystemObject")
set fold = fso.getFolder(Server.MapPath(folder))
fileCount = fold.files.count
dim fNames()
redim fNames(fileCount)
cFcount = 0
for each file in fold.files
cFcount = cFcount + 1
fNames(cFcount) = lcase(file.name)
next
for tName = 1 to fileCount
for nName = (tName + 1) to fileCount
if strComp(fNames(tName),fNames(nName),0)=sort then
buffer = fNames(nName)
fNames(nName) = fNames(tName)
fNames(tName) = buffer
end if
next
next
for i = 1 to fileCount
content = content & "<A HREF='" & folder & "/" & fNames(i) & "'>"& fNames(i) & "</A><br>"
next
Response.Write content
%>

</body>
</html>
 

Bookmark

AddThis Social Bookmark Button


Newsflash

Jack Wallen is the host of the TechRepublic open source blog as well as a regular writer in the "10 Things..." and the "How Do I..." blogs.

In this article Jack Wallen reviews Yadis! Backup.

Some highlights:

There are tons of backup solutions available, ranging from simple, single-user applications to much larger, complex solutions. Most all of these solutions will do what the creators claim — back up your data. You always hope that data is backed up safely and that it will be there in that unforeseen moment when you need it. There is one backup solution amid the myriad of others that offers a unique little twist on the old tried-and-true process. Yadis! Backup.
...

Yadis! Backup is one of the more foolproof backup solutions I’ve come across. If you are looking for a simple backup solution that does not require any scheduling, this might be what you are seeking. It’s not exactly Enterprise-ready, but for smaller backups it’s a pretty sweet solution.

Read the full article here.