Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

function in <cfif> outputs as text

Explorer ,
Jan 26, 2011 Jan 26, 2011

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>

567
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Jan 26, 2011 Jan 26, 2011

Try this:

<cfset fileName = "c:\blahblah">

<cfif FileExits(fileName)>

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

</cfif

Translate
Explorer ,
Jan 26, 2011 Jan 26, 2011

-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 26, 2011 Jan 26, 2011

Try this:

<cfset fileName = "c:\blahblah">

<cfif FileExits(fileName)>

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

</cfif

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 26, 2011 Jan 26, 2011

That did the trick!

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 26, 2011 Jan 26, 2011
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources