Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2004
    Location
    michigan
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Format of files in folder

    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))

    Response.Write("<ul>")
    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
    Next
    Response.Write("</ul>")

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Change this line:
    Code:
    Response.Write("<li><a href=""" & Fldr & x.Name & """>" & Mid(x.Name,1,InStr(x.Name, ".")-1) & "</a></li>")
    To this:
    Code:
    'Response.Write("<li><a href=""" & Fldr & x.Name & """>" & Mid(x.Name, 3, Len(x.Name)-6) & "</a></li>")
    Hope this helps

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    And of course to have a file open in a new browser window you could add something like target='new' to the link...
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #4
    New Coder
    Join Date
    Jun 2004
    Location
    michigan
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    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.

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You're welcome and glad to hear it worked for you...
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •