I’ve recently taken to writing all of my components in pure cfscript. To me, they look cleaner and are easier to navigate. Plus, I just really like cfscript :)

One of the challenges, of course, is that after using tags for so long, it can be sometimes challenging to find equivalent functionality in cfscript. Some tags expose functionality that may not be readily apparent in cfscript functions provided.

Take cffile’s “rename” action. If you look through the list of “FileXXXX()” methods, you’ll see a lot that correspond 1-to-1 with the tag actions. However, interestingly enough, there’s no FileRename() function.

Now you might think that this means that files can’t be renamed with using cffile. Wrong! You can simply use FileMove() to accomplish the rename. And actually, if you think about it, this makes sense. After all, when you move a file, you literally move it–so if the file is moved to a different or same location with a new file name, that’s the file that’s getting moved…no copy to worry about cleaning up after the face.

Ok, enough of that. So here’s a pretty ordinary file rename with cffile:

<cffile action=”rename” source=”c:\files\memo\readonlymemo.doc” destination=”c:\files\memo\normalmemo.doc”>

But we can accomplish precisely the same thing with FileMove():

filemove(c:\files\memo\readonlymemo.doc, c:\files\memo\normalmemo.doc);

Pretty nice!