View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cffile action = "rename" PreviousNext

cffile action = "rename"

Renames or moves a file on the server.

<cffile 
action = "rename"
source = "full_path_name"
destination = "path_name"
mode = "mode"
attributes = "file_attributes_list">

cfdirectory

See the History section of the main cffile tag page.

Attribute

Req/Opt

Default

Description

action

Required

 

Type of file manipulation that the tag performs.

source

Required

 

Pathname of file to rename.

If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.

destination

Required

 

Destination file or directory. If not an absolute path, it is relative to the source directory.

mode

Optional

 

Applies only to UNIX and Linux. Permissions. Octal values of UNIX chmod command. Assigned to owner, group, and other. For example:

  • 644: Assigns read/write permission to owner; read permission to group and other
  • 777: Assigns read/write/execute permission to all

attributes

Optional

 

Applies to Windows. A comma-delimited list of attributes to set on the file.

If omitted, the file's attributes are maintained.

Each value must be specified explicitly. For example, if attributes = "readOnly", all other attributes are overwritten.

  • hidden
  • normal
  • readOnly

The rename action renames or move a file. The destination attribute must be a pathname, not just a new name for the file. If the destination is a directory, the file is moved and not renamed.

The following example renames the file keymemo.doc to oldmemo.doc:

<cffile action = "rename"
   source = "c:\files\memo\keymemo.doc" 
destination = "c:\files\memo\oldmemo.doc">

Contents > CFML Reference > ColdFusion Tags > cffile action = "rename" PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


aminz said on Oct 2, 2003 at 12:09 PM :
I am trying to use CFFILE + RENAME to change the attributes of a file, but it is not working?? Is it a bug?

<CFFILE ACTION="RENAME" SOURCE="#mFile#" DESTINATION="#mFile#_Bad" ATTRIBUTES="Normal">

It does rename the file but it does not change attribute...

Thanks,
AZ
No screen name said on Nov 14, 2003 at 10:22 AM :
I had the same problem with CFFILE RENAME. I was doing an upload then a rename, but found that the upload could change the filename and do it in one step.

Its clear though that the rename doesn't work any more. Maybe it got fixed somewhare.

Dave
No screen name said on Nov 19, 2003 at 3:20 AM :
The same with me... Any rename-action failed. Is there a workaround? Thanx.
lbryngel said on Feb 18, 2004 at 8:39 AM :
We are working to improve the examples in the ColdFusion reference pages. We propose to replace the current example on this page with the the following example. If you have any comments on this example, add them to this page.

Windows Example:
<!--- Source Document is readonly but when renamed it becomes normal i.e. not hidden or readonly --->

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

Unix Example:
<cffile action = "rename" source = "#myWR#/memo/sample.txt" destination = "#myWR#/memo/other_sample.txt" mode="666">
MacAneyth said on Mar 18, 2004 at 2:15 AM :
I have an error with linux when I try to move a file ...
I can copy the file and delete source after.

BUT I CAN NOT MOVE THE FILE
mkbris said on Sep 11, 2004 at 7:07 AM :
Can you please add a description of what happens if you try to rename the file to a file name that already exists? (that is, some file is alread called 'normalmemo.doc').
No screen name said on Oct 8, 2004 at 10:32 AM :
Error Occurred While Processing Request
Attribute validation error for tag CFFILE.
The value of the attribute source, which is currently "C:\inetpub\wwwroot\Docwf\StandardParagraphs\offrefdata1\ReferenceDataWorking.xml", is invalid.

The error occurred in C:\inetpub\wwwroot\Docwf\StandardParagraphs\act_upload.cfm: line 13

11 : <cffile action="move"
12 : ATTRIBUTES="Normal"
13 : source="C:\inetpub\wwwroot\Docwf\StandardParagraphs\offrefdata#n#\ReferenceDataWorking.xml"
14 : destination="ReferenceDataWorking<cfoutput>#DateFormat(Now())#</cfoutput>.xml">
15 : <cffile action="move"


--------------------------------------------------------------------------------

Please try the following:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.


Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
Remote Address 127.0.0.1
Referrer
Date/Time 08-Oct-04 01:31 PM

Stack Trace (click to expand)
at cfact_upload2ecfm1752058874.runPage(C:\inetpub\wwwroot\Docwf\StandardParagraphs\act_upload.cfm:13)


coldfusion.tagext.InvalidTagAttributeException: Attribute validation error for tag CFFILE.
at coldfusion.tagext.io.FileTag.move(FileTag.java:487)
at coldfusion.tagext.io.FileTag.doStartTag(FileTag.java:228)
at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1876)
at cfact_upload2ecfm1752058874.runPage(C:\inetpub\wwwroot\Docwf\StandardParagraphs\act_upload.cfm:13)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:24)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:105)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:249)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:192)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)


I'm getting this error even though the path is valid
jim1234 said on Nov 9, 2004 at 11:59 AM :
I found that I get the source value is invalid when actually it's the destination that is invalid. The error message points you to the wrong parameter. Also, the user that ColdFusion is running under must have write permissions in the directory and for the file (and modify on the file if you want to change the attributes). To overwrite the file you simple set nameconflict="overwrite" in the cffile tag.
No screen name said on Jun 6, 2005 at 8:22 PM :
Searching for this error in Google ("Attribute validation error for tag CFFILE") shows that people get this error intermittently, event when the source and destination exist, which is what I'm observing on a local CFMX server. Someone suggested it has to do with a file lock (?).
dzeimer said on Aug 1, 2005 at 9:46 PM :
Just had this issue as well with the source file showing as the error when actually it was a permissions problem on the destination file.

sent me up the garden path for a bit....
mugafuga said on Jul 25, 2006 at 11:53 AM :
I am experiencing the same error.
I know my paths are correct.
I know my permissions are correct.
I know my code is correct.
Yet I still get the error.
If you have read down this far then this is probably your solution

If you are trying to append your file name with a date MAKE SURE YOU DONT HAVE SLASHES IN IT! instead go with a dash
ie. 01-01-07 instead of 01/01/07 cf will think you are changing the path
Mark (gruden) said on Oct 30, 2006 at 10:00 PM :
I've come across a similar problem - are any of you trying to move from one partition/filesystem/mount to another? If so then I think you are better off going to a copy/delete approach.

See http://www.thescripts.com/forum/thread16215.html, https://bugs.eclipse.org/bugs/show_bug.cgi?id=144296, http://www.velocityreviews.com/forums/t130180-existing-file-copy.html

Tested on CF7/Solaris 10,JDK 1.4.2


Mark

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-p34.htm