DirectoryRename

Description

Renames on-disk or in-memory directory.

Function Syntax

DirectoryRename(currentName,newName)

Usage

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

History

ColdFusion 9: Added this function

Parameters

Parameter

Description

currentName

Absolute path of the directory to be renamed. Alternatively, you can specify IP address, for example, DirectoryRename("//12.3.123.123/c_drive/test");

newName

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>