如何排序和修剪目录列表? [英] How to sort and trim a directory list?
问题描述
我使用以下脚本列出一组文件:
<%set directory = Server.CreateObject(" Scripting.FileSystemObject")
set allfiles = directory.GetFolder(Server.MapPath(" / mmm / lesson /"))
For allFiles.files中的每个目录文件
Response.Write "< a href =''/ mmm / lesson /" &安培; directoryfile.name& ">" &
directoryfile.name& "< / a>"
下一页%>
这显示很棒(感谢Roland!)但是(小)问题是
名称是WeekX.pdf,其中X =一年中的一周。
因此列表显示为:
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf
....
Week19 .pdf
Week2.pdf
Week20.pdf
等
如何显示列出数字顺序并修剪它以便
" .pdf"没有显示?
我想我可以使用修剪功能来移除扩展名,但是我不知道如何用数字方式对这些进行排序。
你不能轻易地对它们进行数字排序,因为它们被命名为
(我不认为..但我累了所以也许我没有想到的正确)
它们被命名为更像这样你可以
Week001.pdf
Week010.pdf
Week011.pdf
Week012.pdf
然后转到下一个问题
最简单的方法来重新选择.pdf每个人都有一个替换标记
替换(无论如何,。pdf,")
替换 ; .PDF"什么都没有
"。:mmac:。 <丢失@海>在留言中写道
新闻:uI ************** @ TK2MSFTNGP09.phx.gbl ...我正在列出一套使用以下脚本的文件:
<%set directory = Server.CreateObject(" Scripting.FileSystemObject")
设置allfiles = directory.GetFolder(Server.MapPath(" /) mmm / lesson /"))
对于allFiles.files中的每个目录文件
Response.Write"< a href =''/ mmm / lesson /" &安培; directoryfile.name& ">" &
directoryfile.name& "< / a>"
下一个%>
这显示很棒(感谢Roland!)但是(次要)问题是
名称是WeekX。 pdf其中X =一年中的一周。
因此列表显示为:
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf > ...
Week19.pdf
Week2.pdf
Week20.pdf
如何显示列表数字顺序并修剪它所以
.pdf没有显示?
我想我可以使用修剪功能删除扩展,但我不知道如何用数字方式对这些进行排序。
然后你进入你将如何排序他们来自技术的问题
观点
你要把它放在一个数组中并运行comlxs排序函数
it br />
或将其放在数据库表中并让SQL语句完成工作
"。:mmac:。" <丢失@海>在留言中写道
新闻:uI ************** @ TK2MSFTNGP09.phx.gbl ...我正在列出一套使用以下脚本的文件:
<%set directory = Server.CreateObject(" Scripting.FileSystemObject")
设置allfiles = directory.GetFolder(Server.MapPath(" /) mmm / lesson /"))
对于allFiles.files中的每个目录文件
Response.Write"< a href =''/ mmm / lesson /" &安培; directoryfile.name& ">" &
directoryfile.name& "< / a>"
下一个%>
这显示很棒(感谢Roland!)但是(次要)问题是
名称是WeekX。 pdf其中X =一年中的一周。
因此列表显示为:
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf > ...
Week19.pdf
Week2.pdf
Week20.pdf
如何显示列表数字顺序并修剪它所以
.pdf没有显示?
我想我可以使用修剪功能删除扩展,但我不知道如何用数字方式对这些进行排序。
嗯,这听起来比它的价值更多。
" Kyle Peterson" < KP ***** @ hotmail.com>在消息中写道
新闻:eo ************** @ TK2MSFTNGP09.phx.gbl ...然后你进入了你将如何对它们进行排序从技术角度提出的问题
要么将它放在一个数组中并运行comlxs排序函数
或者把它放在数据库表中并让一个SQL声明做的工作
"。:mmac:。 <丢失@海>在消息中写道
新闻:uI ************** @ TK2MSFTNGP09.phx.gbl ...我列出了一组文件使用以下脚本:
<%set directory = Server.CreateObject(" Scripting.FileSystemObject")
设置allfiles = directory.GetFolder(Server.MapPath(" / mmm / lesson / ))
对于allFiles.files中的每个目录文件
Response.Write"< a href =''/ mmm / lesson /" &安培; directoryfile.name& ">" &
directoryfile.name& "< / a>"
下一个%>
这显示很棒(感谢Roland!)但是(次要)问题是
名称是WeekX。 pdf其中X =一年中的一周。
因此列表显示为:
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf > ...
Week19.pdf
Week2.pdf
Week20.pdf
如何显示列表数字顺序并修剪它所以
.pdf没有显示?
我想我可以使用修剪功能删除扩展,但我不知道如何用数字方式对这些进行排序。
I am listing a set of files using the following script:
<% set directory = Server.CreateObject("Scripting.FileSystemObject")
set allfiles = directory.GetFolder(Server.MapPath("/mmm/lesson/"))
For Each directoryfile in allFiles.files
Response.Write "<a href=''/mmm/lesson/" & directoryfile.name & "''>" &
directoryfile.name & "</a>"
Next %>
This displays great (thanks Roland!)but the (minor) problem is that the
names are WeekX.pdf where X= week of year.
So the list is displayed as :
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf
....
Week19.pdf
Week2.pdf
Week20.pdf
etc
How can I display the list numerical order and also trim it so that the
".pdf" is not shown?
I imagine there is trim function I can use to remove the extension, but I
have no clue how to sort these numerically this way.
you cannot easily sort them numerically because of the way they are named
(I dont think.. but I am tired so maybe I am not thinking right)
it they were named more like this like this you could
Week001.pdf
Week010.pdf
Week011.pdf
Week012.pdf
then on to the next question
easiest way to remobe the ".pdf" is with a replace stament on each one
replace(whatever,".pdf","")
replacing the ".pdf" with nothing
".:mmac:." <lost@sea> wrote in message
news:uI**************@TK2MSFTNGP09.phx.gbl...I am listing a set of files using the following script:
<% set directory = Server.CreateObject("Scripting.FileSystemObject")
set allfiles = directory.GetFolder(Server.MapPath("/mmm/lesson/"))
For Each directoryfile in allFiles.files
Response.Write "<a href=''/mmm/lesson/" & directoryfile.name & "''>" &
directoryfile.name & "</a>"
Next %>
This displays great (thanks Roland!)but the (minor) problem is that the
names are WeekX.pdf where X= week of year.
So the list is displayed as :
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf
...
Week19.pdf
Week2.pdf
Week20.pdf
etc
How can I display the list numerical order and also trim it so that the
".pdf" is not shown?
I imagine there is trim function I can use to remove the extension, but I
have no clue how to sort these numerically this way.
then you get into the "how you gonna sort them" question from technical
viewpoint
either your going to put it in an array and run comlxs sorting functions on
it
or put it in database table and let a SQL statement do the work
".:mmac:." <lost@sea> wrote in message
news:uI**************@TK2MSFTNGP09.phx.gbl...I am listing a set of files using the following script:
<% set directory = Server.CreateObject("Scripting.FileSystemObject")
set allfiles = directory.GetFolder(Server.MapPath("/mmm/lesson/"))
For Each directoryfile in allFiles.files
Response.Write "<a href=''/mmm/lesson/" & directoryfile.name & "''>" &
directoryfile.name & "</a>"
Next %>
This displays great (thanks Roland!)but the (minor) problem is that the
names are WeekX.pdf where X= week of year.
So the list is displayed as :
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf
...
Week19.pdf
Week2.pdf
Week20.pdf
etc
How can I display the list numerical order and also trim it so that the
".pdf" is not shown?
I imagine there is trim function I can use to remove the extension, but I
have no clue how to sort these numerically this way.
hmmm, that sounds like more work than it''s worth.
"Kyle Peterson" <kp*****@hotmail.com> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...then you get into the "how you gonna sort them" question from technical
viewpoint
either your going to put it in an array and run comlxs sorting functions
on it
or put it in database table and let a SQL statement do the work
".:mmac:." <lost@sea> wrote in message
news:uI**************@TK2MSFTNGP09.phx.gbl...I am listing a set of files using the following script:
<% set directory = Server.CreateObject("Scripting.FileSystemObject")
set allfiles = directory.GetFolder(Server.MapPath("/mmm/lesson/"))
For Each directoryfile in allFiles.files
Response.Write "<a href=''/mmm/lesson/" & directoryfile.name & "''>" &
directoryfile.name & "</a>"
Next %>
This displays great (thanks Roland!)but the (minor) problem is that the
names are WeekX.pdf where X= week of year.
So the list is displayed as :
Week1.pdf
Week10.pdf
Week11.pdf
Week12.pdf
...
Week19.pdf
Week2.pdf
Week20.pdf
etc
How can I display the list numerical order and also trim it so that the
".pdf" is not shown?
I imagine there is trim function I can use to remove the extension, but I
have no clue how to sort these numerically this way.
这篇关于如何排序和修剪目录列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!