Skip to main content
January 26, 2011
Answered

function in <cfif> outputs as text

  • January 26, 2011
  • 2 replies
  • 621 views

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 has been closed for replies.
    Correct answer Scott Stroz

    Try this:

    <cfset fileName = "c:\blahblah">

    <cfif FileExits(fileName)>

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

    </cfif

    2 replies

    Scott StrozCorrect answer
    Participating Frequently
    January 26, 2011

    Try this:

    <cfset fileName = "c:\blahblah">

    <cfif FileExits(fileName)>

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

    </cfif

    January 26, 2011

    That did the trick!

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

    Inspiring
    January 26, 2011

    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

    January 26, 2011

    -