peterevison
asked on
CFDirectory/CFFile
I need to query a database to get the originating path and move ALL files with in that originating path to the destination path(also in the database). Can someone help me out.
Here is what I have but it only moves the files from the first hit in the database query.
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfloop query="directorylist">
<cffile action="move"
source="#filecopy.origin## directoryl ist.name#"
destination="#filemove.des tin#">
</cfloop>
</cfloop>
Here is what I have but it only moves the files from the first hit in the database query.
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfloop query="directorylist">
<cffile action="move"
source="#filecopy.origin##
destination="#filemove.des
</cfloop>
</cfloop>
In you cffile tag
you had
destination="#filemove.des tin#">
which is always going to give you the first record in the query.
That is why you need to change it to this
destination="#filemove.des tin#">
you had
destination="#filemove.des
which is always going to give you the first record in the query.
That is why you need to change it to this
destination="#filemove.des
ASKER
Now I'm getting error "Variable DESTIN is undefined."
Sorry about that
Try this
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfset destin_tmp=destin>
<cfloop query="directorylist">
<cffile action="move"
source="#filecopy.origin## directoryl ist.name#"
destination="#destin_tmp#" >
</cfloop>
</cfloop>
Try this
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfset destin_tmp=destin>
<cfloop query="directorylist">
<cffile action="move"
source="#filecopy.origin##
destination="#destin_tmp#"
</cfloop>
</cfloop>
ASKER
I somewhat works...Execpt when it gets to the second originating directory it looking for the same file name(s) from the first originating directory. And of course that file is not there so it fails.
Its created a constant loop.
Its created a constant loop.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
COOL!
I was able to get it working....Thank you very much for you help.
The finishing touch I also had to add:
<cfset origin_tmp=origin>
So it looks like this:
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfset destin_tmp=destin>
<cfset origin_tmp=origin>
<cfloop query="directorylist">
<cffile action="move"
source="#origin_tmp##name# "
destination="#destin_tmp#" >
</cfloop>
</cfloop>
I was able to get it working....Thank you very much for you help.
The finishing touch I also had to add:
<cfset origin_tmp=origin>
So it looks like this:
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfset destin_tmp=destin>
<cfset origin_tmp=origin>
<cfloop query="directorylist">
<cffile action="move"
source="#origin_tmp##name#
destination="#destin_tmp#"
</cfloop>
</cfloop>
ASKER
CFDevHead,
You should also add a comment to my other posting.
https://www.experts-exchange.com/questions/21718803/List-with-cfdirectory-and-move-with-cffile.html
Its the same question but I never got an answer. So I would like to give you the points for both.
You should also add a comment to my other posting.
https://www.experts-exchange.com/questions/21718803/List-with-cfdirectory-and-move-with-cffile.html
Its the same question but I never got an answer. So I would like to give you the points for both.
<cfquery name="filemove" datasource="server">
select * from filemove
</cfquery>
<cfloop query="filemove">
<cfdirectory action="LIST" directory="#origin#" name="directoryList">
<cfloop query="directorylist">
<cffile action="move"
source="#filecopy.origin##
destination="#destin#">
</cfloop>
</cfloop>