Whatever message this page gives is out now! Go check it out!

DirectoryRename

Last update:
May 18, 2026

Description

Renames on-disk or in-memory directory.

Category

Function Syntax

DirectoryRename(oldPath,newPath)

See Also

Usage

Ensure that you have the required permissions to run this function.

History

ColdFusion (2018 release): Renamed the following parameters:
  • path to oldPath
  • newName to newPath
ColdFusion 9: Added this function

Parameters

Parameter
Description
oldPath
Absolute path of the directory to be renamed. Alternatively, you can specify IP address, for example, DirectoryRename("//12.3.123.123/c_drive/test");
newPath
Name with which the directory has to be renamed.

Example

<h2>DirectoryRename Example</h2> 
<h3>Enter a directory to rename.</h3> 
<cfform action = "directoryRename.cfm" method="post" preservedata="true" > 
<label for="renameDirectory">Directory to rename: </label><cfinput required="true" type = "text" id="renameDirectory" name = "renameDirectory"> 
<br/> 
<label for="newName">New Name: </label><cfinput required="true" type="text" id="newName" name = "newName"> 
<br/> 
<input type = "submit" value="submit" name="submit"> 
</cfform> 

<cfif IsDefined("FORM.renameDirectory") and IsDefined("FORM.newName") > 
<cfif FORM.renameDirectory is not "" and FORM.newName is not ""> 
<cfset renameDirectory = FORM.renameDirectory> 
<cfset newName = FORM.newName> 
<cftry> 
<cfset DirectoryRename(renameDirectory,newName)> 
<cfoutput><b>Directory #renameDirectory# renamed to newName</b></cfoutput> 
<cfcatch> 
<b>Error Message:</b><cfoutput>#cfcatch.message#</cfoutput><br/> 
<b>Error Detail:</b><cfoutput>#cfcatch.Detail#</cfoutput> 
</cfcatch> 
</cftry> 
</cfif> 
</cfif>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page