Description

Renames on-disk or in-memory directory.

Category

System functions

Function Syntax

DirectoryRename(oldPath,newPath)

See Also

DirectoryCreateDirectoryDeleteDirectoryExistsDirectoryList

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>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy