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##directorylist.name#"
   destination="#filemove.destin#">
   
   </cfloop>
   </cfloop>
peterevisonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CFDevHeadCommented:
tRY THIS.
<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##directorylist.name#"
            destination="#destin#">
      </cfloop>
</cfloop>
CFDevHeadCommented:
In you cffile tag
you had

 destination="#filemove.destin#">
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.destin#">
peterevisonAuthor Commented:
Now I'm getting error "Variable DESTIN is undefined."
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

CFDevHeadCommented:
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##directorylist.name#"
          destination="#destin_tmp#">
     </cfloop>
</cfloop>
peterevisonAuthor Commented:
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.
CFDevHeadCommented:
I over looked this

source="#filecopy.origin##directorylist.name#

change it to
source="#filecopy.origin##name#

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peterevisonAuthor Commented:
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>

peterevisonAuthor Commented:
CFDevHead,

You should also add a comment to my other posting.

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21718803.html

Its the same question but I never got an answer.  So I would like to give you the points for both.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.