ASP VbScript Replace

Posted on 2012-09-05
Last Modified: 2012-09-06
Dear Experts

I am displaying the value from a database field on a webpage.  

The field I am displaying is via the code <%=RTRIM(images.Fields.Item("docfilename").Value)%>

If the value of the field displayed above was 'filename.jpg'  - I am looking for a way to be able to display this as 'filename_small.jpg'

Basically I need to try and find a way of inserting '_small' to the value before the '.jpg'

Can anyone offer any advise on how to achieve this?

Question by:grantballantyne
    LVL 74

    Accepted Solution


    <%=Replace(RTRIM(images.Fields.Item("docfilename").Value), ".jpg", "_small.jpg")%>

    Open in new window

    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    Do you want to display it as a link using a different name like <a href="<%=RTRIM(images.Fields.Item("docfilename").Value)%>"> <%=replace(RTRIM(images.Fields.Item("docfilename").Value),".jpg","_small.jpg")%>

    or do you want to actually change the file name with fso

        set fso = CreateObject("Scripting.FileSystemObject")
        set file = fso.GetFile("c:\website\images\imagname.jpg") = "c:\website\images\imagname_small.jpg"
        set file = nothing
        set fso = nothing

    Then later on you can access the file <img src="/images/imagename_small.jpg">

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now