Description:-

This is used to rename a directory on disk or in memory if you have the required permissions to run this function.

directoryRename( oldPath, newPath );

Attributes:-

oldPath:- - This is a required attribute, and the name of the old directory is to be renamed on an absolute on-disk or in-memory location. Alternatively, you can specify the IP address as in the bellow example:
directoryRename( "//192.168.0.1/new_disc/test", "" );

newPath:- This is a required attribute, and the name of the new directory is to be newly renamed on an absolute on-disk or in-memory location. Alternatively, you can specify the IP address as in the bellow example:
directoryRename( "", "//192.168.0.1/new_disc/test" );

Example:-

In this example, we will rename this d:\files\documents directory to d:\files\tests in Windows and check if this is created or not.

<cfscript>
    if ( !directoryExists( "d:\files\documents" ) ){
        directoryCreate( "d:\files\documents" );
    }

    writeOutput( "Before Rename old: #directoryExists( "d:\files\documents" )#" );
    writeOutput( "Before Rename new: #directoryExists( "d:\files\tests" )#" );

    directoryRename( "d:\files\documents", "d:\files\tests" );

    writeOutput( "After Rename old: #directoryExists( "d:\files\documents" )#" );
    writeOutput( "After Rename new: #directoryExists( "d:\files\tests" )#" );
</cfscript>

Result:-

Before Rename old: YES
Before Rename new: NO
After Rename old: NO
After Rename new: YES

In our system, we create this d:\files\documents directory first then check if our old and new directories exist or not as per the result our old one exists but the new one does not, after the rename operation we also check which one exists now, as per result old one is not exist but newly rename directory is exist now.