Albee_J
asked on
Coldfusion if directory exists delete and recreate
I am having a hard time with the syntax. I am trying to take my existing code and check if a directory already exists by that name. If it does I want to delete it and recreate it.
Here is the existing code:
I see tutorials on this page http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_d-e_03.html but I am messing up the syntax :/
Here is the existing code:
I see tutorials on this page http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_d-e_03.html but I am messing up the syntax :/
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafiles\X-Change\All Users\',Arguments.SlideShow) gt 0>
<cfdirectory action="list" directory="#Arguments.SlideShow#" filter="*.gif|*.png|*.jpg" name="getImages">
<cfset SlideShowFolder = listgetat(SlideShow,listlen(Arguments.SlideShow,'\'),'\')>
<cfdirectory action="create" directory="E:\Coldfusion8\wwwroot\FMAF-Administrator\Camp-Slideshows\#SlideShowFolder#">
<cfftp action="open"
username="****"
password="*****"
server="****"
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolder#" connection="images">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.SlideShow#\#getImages.name#" remotefile="#getImages.name#">
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
ASKER
Gotta be my directory path then, I will double check
yes! pretty Straight like agx said
<cfset theDirecPath = "c:\something\orOther\">
<cfif DirectoryExists(theDirecPa th)>
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#theDirecPath#" recurse="yes">
</cfif>
<cfif NOT DirectoryExists(theDirecPa th)>
<cfdirectory action="create" directory="#theDirecPath#" >
</cfif>
it will also work
<cfset theDirecPath = "c:\something\orOther\">
<cfif DirectoryExists(theDirecPa
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#theDirecPath#"
</cfif>
<cfif NOT DirectoryExists(theDirecPa
<cfdirectory action="create" directory="#theDirecPath#"
</cfif>
it will also work
ASKER
I found the problem, I needed to delete and recreate in two areas, my local and live. Keeping a copy on my local
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafi les\X-Chan ge\All Users\',Arguments.SlideSho w) gt 0>
<cfset SlideShowFolder = listgetat(SlideShow,listle n(Argument s.SlideSho w,'\'),'\' )>
<cfset homeDirecPath = "E:\Coldfusion8\wwwroot\FM AF-Adminis trator\Cam p-Slidesho ws\#SlideS howFolder# ">
<cfset siteDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
<cfif DirectoryExists(homeDirecP ath) AND DirectoryExists(siteDirecP ath)>
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#homeDirecPath# " recurse="yes">
<cfdirectory action="delete" directory="#siteDirecPath# " recurse="yes">
<cfif NOT DirectoryExists(theDirecPa th)>
<cfdirectory action="list" directory="#Arguments.Slid eShow#" filter="*.gif|*.png|*.jpg" name="getImages">
<cfdirectory action="create" directory="E:\Coldfusion8\ wwwroot\FM AF-Adminis trator\Cam p-Slidesho ws\#SlideS howFolder# ">
<cfftp action="open"
username="***"
password="***"
server="***"
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde r#" connection="images">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid eShow#\#ge tImages.na me#" remotefile="#getImages.nam e#">
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
</cfif>
</cfif>
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafi
<cfset SlideShowFolder = listgetat(SlideShow,listle
<cfset homeDirecPath = "E:\Coldfusion8\wwwroot\FM
<cfset siteDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
<cfif DirectoryExists(homeDirecP
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#homeDirecPath#
<cfdirectory action="delete" directory="#siteDirecPath#
<cfif NOT DirectoryExists(theDirecPa
<cfdirectory action="list" directory="#Arguments.Slid
<cfdirectory action="create" directory="E:\Coldfusion8\
<cfftp action="open"
username="***"
password="***"
server="***"
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
</cfif>
</cfif>
I don't see that adaptation adding any benefit. Since the goal is to perform 2 actions, then both be grouped together within the same CFIF block. If nothing else, it's more logical and intuitive.
ASKER
Not giving me an error but it doesn't look like it is deleting the existing files and pulling the new. I added about 4 more images to the folder and tested. No error, but it didn't recreate the folder right. If it did the 4 new images would have shown up.
Albee_J - our posts crossed. That last response was not regarding your code.
ASKER
Not sure what you mean agx?
>> I needed to delete and recreate in two areas,
Are you sure you're doing _both_ steps for both folders? I'm not seeing to "create" actions...
Are you sure you're doing _both_ steps for both folders? I'm not seeing to "create" actions...
ASKER
What it does not that I like it, is create just the folder on my local, then creates on live with files.
Not sure how to fix
Not sure how to fix
>> Not sure what you mean agx?
I just meant our posts keep crossing. So our responses are out-of-synch and may not make sense.
I just meant our posts keep crossing. So our responses are out-of-synch and may not make sense.
I'm not sure the folders and variables are right. It seems like something is missing.
You seem to be deleting these 2 folders
<cfdirectory action="delete" directory="#homeDirecPath# " recurse="yes">
<cfdirectory action="delete" directory="#siteDirecPath# " recurse="yes">
Then using a totally different variable?
<cfif NOT DirectoryExists(theDirecPa th)>
Then re-creating only 1 of the folders...? I would have expected 2 create statements
<cfdirectory action="create" directory="E:\Coldfusion8\ wwwroot\FM AF-Adminis trator\Cam p-Slidesho ws\#SlideS howFolder# ">
You seem to be deleting these 2 folders
<cfdirectory action="delete" directory="#homeDirecPath#
<cfdirectory action="delete" directory="#siteDirecPath#
Then using a totally different variable?
<cfif NOT DirectoryExists(theDirecPa
Then re-creating only 1 of the folders...? I would have expected 2 create statements
<cfdirectory action="create" directory="E:\Coldfusion8\
ASKER
>> I just meant our posts keep crossing. So our responses are out-of-synch and may not make sense.
:) I understand agx
The code as it stands doesn't really recreate the whole folder. It just doesn't error out. Not sure how to fix that
ASKER
>>Then using a totally different variable?
I just fixed that. Lemme check my code agian
I just fixed that. Lemme check my code agian
ASKER
I'm getting rid of this line, I don't need it
<!--- <cfdirectory action="create" directory="E:\Coldfusion8\ wwwroot\FM AF-Adminis trator\Cam p-Slidesho ws\#SlideS howFolder# ">--->
<!--- <cfdirectory action="create" directory="E:\Coldfusion8\
ASKER
Ok here is the revised code. But it is still not truly deleting and recreating the directory. I added 4 more images to my folder and ran the code. They did not appear on the live.
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafi les\X-Chan ge\All Users\',Arguments.SlideSho w) gt 0>
<cfset SlideShowFolder = listgetat(SlideShow,listle n(Argument s.SlideSho w,'\'),'\' )>
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
<cfif DirectoryExists(theDirecPa th)>
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#theDirecPath#" recurse="yes">
<cfif NOT DirectoryExists(theDirecPa th)>
<cfdirectory action="list" directory="#Arguments.Slid eShow#" filter="*.gif|*.png|*.jpg" name="getImages">
<!--- <cfdirectory action="create" directory="E:\Coldfusion8\ wwwroot\FM AF-Adminis trator\Cam p-Slidesho ws\#SlideS howFolder# ">--->
<cfftp action="open"
username=" "
password=" "
server=""
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde r#" connection="images">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid eShow#\#ge tImages.na me#" remotefile="#getImages.nam e#">
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
</cfif>
</cfif>
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafi
<cfset SlideShowFolder = listgetat(SlideShow,listle
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
<cfif DirectoryExists(theDirecPa
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#theDirecPath#"
<cfif NOT DirectoryExists(theDirecPa
<cfdirectory action="list" directory="#Arguments.Slid
<!--- <cfdirectory action="create" directory="E:\Coldfusion8\
<cfftp action="open"
username=" "
password=" "
server=""
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
</cfif>
</cfif>
So what's the current code, and what is it doing/not doing?
ASKER
The current code is above your last post. It is now not pulling all the images up
(Here we go again with the cross posts ... ;-)
I think there's too many different path variables and hard coded paths. That might be part of the problem. Do you really need all of the different permutations?
For example, what's this value
Localfile="#Arguments.Slid eShow#\#ge tImages.na me#
... and how does it relate to all of the others
<cfset SlideShowFolder = listgetat(SlideShow,listle n(Argument s.SlideSho w,'\'),'\' )>
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
.... directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
.... #SlideShowFolder#" connection="images">
....directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/"
I think there's too many different path variables and hard coded paths. That might be part of the problem. Do you really need all of the different permutations?
For example, what's this value
Localfile="#Arguments.Slid
... and how does it relate to all of the others
<cfset SlideShowFolder = listgetat(SlideShow,listle
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
.... directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
.... #SlideShowFolder#" connection="images">
....directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/"
Let's try this again.
I think your condition is backward.
<cfif DirectoryExists(theDirecPa th)>
<cfdirectory action="delete" directory="#theDirecPath#" recurse="yes">
this will never execute because you just deleted the directory .....
<cfif NOT DirectoryExists(theDirecPa th)>
.... do ftp stuff .....
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
</cfif>
I think your condition is backward.
<cfif DirectoryExists(theDirecPa
<cfdirectory action="delete" directory="#theDirecPath#"
this will never execute because you just deleted the directory .....
<cfif NOT DirectoryExists(theDirecPa
.... do ftp stuff .....
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
</cfif>
>> this will never execute because you just deleted the directory .....
No, that's incorrect.
With all the nested cfif's, I'd add some debugging code so you can see which steps are executing and when. Not to mention, check the cfftp status to make sure it's actually doing something.
No, that's incorrect.
With all the nested cfif's, I'd add some debugging code so you can see which steps are executing and when. Not to mention, check the cfftp status to make sure it's actually doing something.
ASKER
Yes.
<cfset SlideShowFolder = listgetat(SlideShow,listle n(Argument s.SlideSho w,'\'),'\' )>
is giving me just the folder name from the url that the files are coming from. That is being stored in the database and used to point to the right folder to build the slideshow with.
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
Is looking for the folder on the live server
<cfdirectory action="list" directory="#Arguments.Slid eShow#" filter="*.gif|*.png|*.jpg" name="getImages">
Is getting all of the images that are stored in the folder located on the users computer (our xchange server)
This creates the directory and loops through all the images to pull them up
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde r#" connection="images">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid eShow#\#ge tImages.na me#" remotefile="#getImages.nam e#">
</cfloop>
<cfset SlideShowFolder = listgetat(SlideShow,listle
is giving me just the folder name from the url that the files are coming from. That is being stored in the database and used to point to the right folder to build the slideshow with.
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/">
Is looking for the folder on the live server
<cfdirectory action="list" directory="#Arguments.Slid
Is getting all of the images that are stored in the folder located on the users computer (our xchange server)
This creates the directory and loops through all the images to pull them up
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid
</cfloop>
ASKER
The code worked perfectly until I added the code to try and delete and recreate the existing directory
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafi les\X-Chan ge\All Users\',Arguments.SlideSho w) gt 0>
<cfdirectory action="list" directory="#Arguments.Slid eShow#" filter="*.gif|*.png|*.jpg" name="getImages">
<cfset SlideShowFolder = listgetat(SlideShow,listle n(Argument s.SlideSho w,'\'),'\' )>
<cfftp action="open"
username=" "
password=" "
server=" "
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde r#" connection="images">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid eShow#\#ge tImages.na me#" remotefile="#getImages.nam e#">
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
<!---Slide Show--->
<cfif findnocase('\\fmafs1\fmafi
<cfdirectory action="list" directory="#Arguments.Slid
<cfset SlideShowFolder = listgetat(SlideShow,listle
<cfftp action="open"
username=" "
password=" "
server=" "
connection="images"
passive="Yes"
stopOnError = "Yes"
timeout = "1200"
retrycount="1">
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="createdir" directory="#SlideShowFolde
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#/" connection="images">
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#Arguments.Slid
</cfloop>
<cfftp action = "close"
connection = "images">
<cfset Image = "">
<cfelse>
<cfset Image = "">
</cfif>
Given the nested cfif's it sounds like the logic may have been added in the wrong place.
What does the code look like without the delete (ie working code)?
What does the code look like without the delete (ie working code)?
Never mind, I see that's the new code.
Well it's either 1 of 2 things. Either one of the variables you created in the new code are wrong OR the CFIF structure is wrong. That's why I suggested adding debugging.
Unfortunately, I'm late for a call right now. So I have to step off for an hour or so.
Well it's either 1 of 2 things. Either one of the variables you created in the new code are wrong OR the CFIF structure is wrong. That's why I suggested adding debugging.
Unfortunately, I'm late for a call right now. So I have to step off for an hour or so.
ASKER
No problem agx, I appreciate your help!
ASKER
Still working on the issue but I know I can't use <cfdirectory> because I am trying to remove files from a remote server. I can delete using
<cfftp action="RemoveDir" directory="#SlideShowFolde r#" connection="images">
<cfftp action="RemoveDir" directory="#SlideShowFolde
Just back from my meeting, and I was going to ask you about that. Though you said delete a directory, looking at the code I realized you were probably trying to delete a folder on the remote ftp server instead.
So you always want to remove the remove the remote ftp folder (assuming it exists)?
So you always want to remove the remove the remote ftp folder (assuming it exists)?
ASKER
I have the code in place to remove the directory and its files. I just need to put in the cfif logic right now
<!--- Check whether the directory exists. --->
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#">
<!---<cfif DirectoryExists(theDirecPa th)>--->
<!--- If yes, check whether there are files in the directory before deleting. --->
<CFFTP Connection="Images" Action="ListDir" Directory="#theDirecPath#" Name="Listing">
<CFloop index="x" From="1" to="#Listing.RecordCount#" >
<CFFTP Connection="Images" Action="Remove" Item="#Listing.Path[x]#">
</CFLOOP>
<!--- Directory is empty - just delete the directory. --->
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="RemoveDir" directory="#SlideShowFolde r#" connection="images">
<cfoutput>
<p>The directory existed and has been deleted.</P>
</cfoutput>
<!--- </cfif>--->
<cfabort>
<!--- Check whether the directory exists. --->
<cfset theDirecPath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/#SlideShowFolder#">
<!---<cfif DirectoryExists(theDirecPa
<!--- If yes, check whether there are files in the directory before deleting. --->
<CFFTP Connection="Images" Action="ListDir" Directory="#theDirecPath#"
<CFloop index="x" From="1" to="#Listing.RecordCount#"
<CFFTP Connection="Images" Action="Remove" Item="#Listing.Path[x]#">
</CFLOOP>
<!--- Directory is empty - just delete the directory. --->
<cfftp action="changedir" directory="/www.nutsandboltsfoundation.org/Manufacturing-Camps/" connection="images">
<cfftp action="RemoveDir" directory="#SlideShowFolde
<cfoutput>
<p>The directory existed and has been deleted.</P>
</cfoutput>
<!--- </cfif>--->
<cfabort>
ASKER
It is definitely not liking this with the cfftp it seems to be ignoring it.
<cfif DirectoryExists(theDirecPa th)>
<cfif DirectoryExists(theDirecPa
>> I just need to put in the cfif logic right now
Using something like cfftp action="existsDir"? Okay.
BTW: In case you were interested, this was what I had in mind when I mentioned condensing the variables and removing all the extra/hard-coded paths. There's only 2 lines containing hard coded paths. So I think it's easier to read and maintain.
*Obviously not tested, and based on the working version (without the delete folder code).
Using something like cfftp action="existsDir"? Okay.
BTW: In case you were interested, this was what I had in mind when I mentioned condensing the variables and removing all the extra/hard-coded paths. There's only 2 lines containing hard coded paths. So I think it's easier to read and maintain.
*Obviously not tested, and based on the working version (without the delete folder code).
....
<!--- Set REMOTE paths --->
<cfset RemotePath = "/www.nutsandboltsfoundation.org/Manufacturing-Camps/">
<!--- Set LOCAL paths (ie xchange server) --->
<cfset LocalPath = "\\fmafs1\fmafiles\X-Change\All Users\">
<cfif findnocase(LocalPath, Arguments.SlideShow) gt 0>
<!--- Get list of local images --->
<cfset LocalFolderName = listLast(Arguments.SlideShow,'\')>
<cfset RemoteFolderName = LocalFolderName >
<cfdirectory action="list" directory="#LocalPath#" filter="*.gif|*.png|*.jpg" name="getImages">
<!--- Connect to REMOTE server --->
<cfftp action="open" username=" " password=" " server=" " connection="images" passive="Yes" stopOnError = "Yes" timeout = "1200" retrycount="1">
<!--- Create directory on REMOTE server --->
<cfftp action="changedir" directory="#RemotePath#" connection="images">
<cfftp action="createdir" directory="#RemoteFolderName#" connection="images">
<cfftp action="changedir" directory="#RemotePath#/#RemoteFolderName#/" connection="images">
<!--- Copy images from LOCAL to REMOTE server --->
<cfloop query="getImages">
<cfftp action="PUTFILE" connection="images" passive="Yes" stopOnError="Yes" Localfile="#LocalPath#\#getImages.name#" remotefile="#getImages.name#">
</cfloop>
</cfif>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<cfset theDirecPath = "c:\something\orOther\">
<cfif DirectoryExists(theDirecPa
<!--- add RECURSE to delete all subfolders as well ....--->
<cfdirectory action="delete" directory="#theDirecPath#"
<cfif NOT DirectoryExists(theDirecPa
<cfdirectory action="create" directory="#theDirecPath#"
</cfif>
</cfif>