Skip to main content
Known Participant
May 1, 2009
Question

mutilple file move by using cffile

  • May 1, 2009
  • 1 reply
  • 2230 views

Hi Guys,

            I am new to CF I like it, I am trying to move files from a floder in a directory to another folder in another directory, I am able to move one file at a time but I want to move them all at a time, Any suggestions?

Thanks much.

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    May 1, 2009

    There is no <cffile..> short cut to move multiple files.  But is a very basic task to use <cfdirectory...> with a loop over a <cffile...> to do what you are asking.

    <cfdirectory dir="DirToMove" name="dirQry"...>

    <cfloop query="dirQry">

      <cffile action="move" from="dirToMove/#dirQry.name#" to "dirToMoveTo/#dirQry.name#"...>

    </cfloop>

    Note: Syntax only hinted at, check published documentation for exact and correct parameters.

    Known Participant
    May 1, 2009

    Hi,

    Thanks for u r response but I think I am doing some thing wrong

    Files in c:\
    ]]>

    It genereating error saying

    An exception occurred when performing a file operation moving a file to

    another filesystem on files D:\a and C:\test. The cause of this exception

    was: java.io.FileNotFoundException: D:\a (Access is denied).

    Could you help me here?

    Dinesh Rachala

    ilssac
    Inspiring
    May 1, 2009

    Your file upload is still "QUEUED" at the time of this writting.  It is usually better to just include relevant excerpts of code in your posts rather then upload entire files since it can be very time consuming for an outsider to look through potentially large files for a relavant group of lines.

    But you mentioned some key concepts in this post.  One, another file system. Two, d:\ versus c:\.

    First of all, the default windows installation of a ColdFusion server is configured to run under a 'localsystem' user which only has permissions to read and write files on, surpise, the local system.  To do file operations such as <cfdirectory...> and <cffile...> the ColdFusion server windows service must be configured to run as a domain user that has permissions to the desired system.  This is easily done with the Windows services manager to set the "log on as" property of the desired ColdFusion service.

    Secondly, when accessing other serves, the drive names such as "c" and "d" are usually meaning less as these are often user specific mappings that can vary from user to user even users on the same system.  The preferd solution is to use UNC paths.  The usual UNC syntax looks something like <cfdirectory dir="\\serverName\directoryName\fileName"...>