View Full Version : Format of files in folder

08-09-2005, 12:47 AM
I got this script that will list all the files in my folder on my website and link to them. I was wondering how I can modify it to strip off the 1st 2 numbers in the name? (they are only there for my filing purposes and have nothing to do with the file name).
Maybe even replace them with an icon?

Your help would be greatly appreciated.

**** The Code ******
dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(Server.MapPath(Fldr))

For Each x In fo.files
If Right(x.Name,3)="pdf" Then
Response.Write("<li><a href=""" & Fldr & x.Name & """>" & Mid(x.Name,1,InStr(x.Name, ".")-1) & "</a></li>")
End If

08-09-2005, 02:37 PM
Change this line:

Response.Write("<li><a href=""" & Fldr & x.Name & """>" & Mid(x.Name,1,InStr(x.Name, ".")-1) & "</a></li>")

To this:

'Response.Write("<li><a href=""" & Fldr & x.Name & """>" & Mid(x.Name, 3, Len(x.Name)-6) & "</a></li>")

Hope this helps


08-10-2005, 01:24 AM
And of course to have a file open in a new browser window you could add something like target='new' to the link... :)

08-10-2005, 02:37 AM
That worked great!! Thanks.
Now I understand the response line more too.

The open in new window idea is one I hadn't thought of, but is a GREAT idea.
Thanks alot.

08-10-2005, 02:42 AM
You're welcome and glad to hear it worked for you... :)