Skip to main content
Jan 26, 2011 6:08 PM UTC
Answered

function in <cfif> outputs as text

Trival problem I'm

sure but I've been going round and round with it...

I'm trying to add an extension to an existing file, but instead of executing the FileMove() function it spits it out as text.  I've tried a few variations but I'm not getting anywhere with it.

<cfset fileName = "c:\blahblah">

<cfif FileExits(fileName)>

     FileMove("#fileName#","#fileName#.txt")

</cfif>

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Scott StrozCorrect answer
    Participating Frequently
    Jan 26, 2011 6:55 PM UTC

    Try this:

    <cfset fileName = "c:\blahblah">

    <cfif FileExits(fileName)>

    <cfset FileMove("#fileName#","#fileName#.txt") />

    </cfif

    4 replies

    Scott StrozCorrect answer
    Participating Frequently
    Jan 26, 2011 6:55 PM UTC

    Try this:

    <cfset fileName = "c:\blahblah">

    <cfif FileExits(fileName)>

    <cfset FileMove("#fileName#","#fileName#.txt") />

    </cfif

    Translate
    Jan 26, 2011 7:26 PM UTC

    That did the trick!

    I never would have thought to use <cfset>...I must have missed that in the documentation.

    Translate
    Inspiring
    Jan 26, 2011 8:05 PM UTC

    fileMove() is just a function, like any other function.  You'd not do this, would you:

    <cfoutput>

    list2 = listAppend(list1, "foo")

    </cfoutput>

    ?

    CF will see anything that is not within a CFML tag or pound-signs as text.

    --

    Adam

    Translate
    Jan 26, 2011 6:12 PM UTC

    -

    Translate