In ColdFusion I am setting up a new directory with <cfdirectory
. Then I need to copy several files from one directory to the new one, keeping the same filenames. I can use a loop to do this, but am wondering if there is any function in cffile that would allow me to copy multiple files at one time.
Cumbersome -- With reploc and newloc being source and target directories:
<cfdirectory
directory = 'newloc'
action = 'create'
mode = 777>
<cfoutput>
<cfset extrep = ExpandPath('reploc')>
<cfset extnew = ExpandPath('newloc')>
<cfset flist = 'a.cfm', 'b.cfm'>
<cfloop list = '#flist#' index = 'item'>
<cffile
action = "copy"
source = "#extrep#/#item#"
destination = "#extnew#/#item#"
mode = "766" >
</cfloop>
</cfoutput>
I have exactly four files to copy. They are fixed and do not depend on any user input.
I was hoping <cffile
would support copying multiple files, but I can't find anything that says it will. Can anyone suggest a more streamlined approach to setting up this directory with its four files?