Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List files alphabetically

Status
Not open for further replies.

exodus300

Programmer
Mar 22, 2002
262
AU
How to sort alphabetically the results of the following code? (Currently they are sorted in some other order, most probably date last accessed/modified)


Code:
<ul>
<%
Dim oFSO 
Set oFSO= Server.CreateObject(&quot;Scripting.FileSystemObject&quot;) 
Dim rootFolder
Set rootFolder = oFSO.GetFolder(&quot;C:\My Documents\Music&quot;)
Dim files, file, fileCount
Set files = rootFolder.Files
For Each file in files        
	If LCase(Mid(file.Name, Len(file.Name) - 2, 4)) = &quot;mp3&quot; Then
		Response.Write &quot;<li><a href=&quot;&quot;&quot; & file.name & &quot;&quot;&quot;>&quot; & LCase(Mid(file.Name, 1, Len(file.Name) - 4)) & &quot;</a>&quot;
	End If
Next 
%>
</ul>

[Thanks in advance|Hope I helped you]
Exodus300
[pc3]
 
a quick answer would be to add the names to a array and sort them that way.

this script shows you with this same task

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top