Tony, Thank you very much for your help! I'm outputting all the txt file
names that are in the directory but the PUTFILE is not working. Any
ideas? This code works just to give you an idea of the structure that works.
<cfftp connection="movefiles" action="GetFile"
remotefile="untitled.txt"
localfile="C:\Inetpub\wwwroot\CFFTP\file_folder\untitled.txt"
transfermode="binary"
timeout="30" retrycount="3" stoponerror="no" failifexists="no">
Thanks Again,
James Blaha
<body bgcolor="#0090FF">
<!--- GET LIST OF TEXT FILES --->
<CFDIRECTORY ACTION="LIST" DIRECTORY="C:\Inetpub\wwwroot\CFFTP"
NAME="confirmfiles" FILTER="*.txt" SORT="datelastmodified ASC">
<cfoutput>The number of text files found in the directory are:
<strong>#confirmfiles.recordCount#</strong></cfoutput><br>
<CFOUTPUT QUERY=confirmfiles> <br>
<table border="1" width="40%">
<tr bordercolor="##333333" bgcolor="##FFFFFF">
<td width="127"><b>Name:</b></td>
<td width="172"><i>#name# </i></td>
</tr>
<tr bordercolor="##333333" bgcolor="##FFFFFF">
<td width="127"><b>Size:</b></td>
<td width="172"><i>#size# </i></td>
</tr>
<tr bordercolor="##333333" bgcolor="##FFFFFF">
<td width="127"><b>Type:</b></td>
<td width="172"><i>#type# </i></td>
</tr>
<tr bordercolor="##333333" bgcolor="##FFFFFF">
<td width="127"><b>Date last modified:</b></td>
<td width="172"><i>#datelastmodified# </i></td>
</tr>
<tr bordercolor="##333333" bgcolor="##FFFFFF">
<td width="127"><b>Attributes:</b></td>
<td width="172"><i>#attributes# </i></td>
</tr>
<tr bordercolor="##333333" bgcolor="##FFFFFF">
<td width="127"><b>Mode:</b></td>
<td width="172"><i>#mode# </i></td>
</tr>
</table>
</CFOUTPUT>
<hr>
<CFIF confirmfiles.recordCount>
<!--- open ftp connection --->
<CFFTP ACTION="OPEN"
STOPONERROR="NO"
CONNECTION="ftpserver_name"
PASSIVE="NO"
USERNAME="anonymous"
PASSWORD="guest@unknown"
SERVER="127.0.0.1">
<CFIF CFFTP.Succeeded is "No">
<h1>An Error has occurred!</h1>
Your attempt to connect to an FTP server has failed with the
following error message:
<UL><LI><cfoutput>#cfftp.ErrorText#</cfoutput></LI></UL>
<CFELSE>
Your connection to the FTP server has succeeded!<br><br>
</CFIF></CFIF>
Below are the files being tranfered:<br>
<CFLOOP QUERY="confirmfiles">
<cfoutput><strong>#confirmfiles.name#</strong><br></cfoutput>
</CFLOOP>
<!--- put each order file --->
<CFLOOP QUERY="confirmfiles">
<CFFTP ACTION="PUTFILE"
STOPONERROR="NO"
TRANSFERMODE="ASCII"
CONNECTION="ftpserver_name"
PASSIVE="No"
REMOTEFILE="/#confirmfiles.name#"
LOCALFILE="C:\Inetpub\wwwroot\CFFTP\file_folder\#confirmfiles.name#">
</CFLOOP>
Tony Schreiber wrote:
>Here's what I use, straight from my server, so substitute your variables
>where necessary:
>
><CFSET message = "">
>
><!--- GET LIST OF CONFIRM FILES --->
><CFDIRECTORY ACTION="LIST" DIRECTORY="#half_confirmdir_local#"
>NAME="confirmfiles" FILTER="*.pdv" SORT="datelastmodified ASC">
><CFSET message = message & "#confirmfiles.recordCount# confirm files
>found.<BR>">
>
><CFIF confirmfiles.recordCount>
>
> <!--- open ftp connection --->
> <CFFTP ACTION="OPEN" STOPONERROR="NO" CONNECTION="half"
>PASSIVE="NO"
> SERVER="#half_ftpserver#" USERNAME="#half_username#"
>PASSWORD="#half_password#">
>
> <CFIF CFFTP.Succeeded>
>
> <CFSET message = message & "Connection opened to
>#half_ftpserver#.<BR>">
>
> <!--- put each order file --->
> <CFLOOP QUERY="confirmfiles">
>
> <CFFTP ACTION="PUTFILE" STOPONERROR="NO"
>TRANSFERMODE="ASCII" CONNECTION="half" PASSIVE="No"
>
>LOCALFILE="#half_confirmdir_local#\#confirmfiles.name#"
>REMOTEFILE="#half_confirmdir#/#confirmfiles.name#">
>
> <CFIF CFFTP.Succeeded>
> <CFSET message = message & "#name#
>uploaded to #half_confirmdir#.<BR>">
> <CFFILE ACTION="MOVE"
>
>SOURCE="#half_confirmdir_local#\#confirmfiles.name#"
>
>DESTINATION="#half_confirmdir_done#\#confirmfiles.name#">
> <CFSET message = message &
>"#confirmfiles.name# moved to #half_confirmdir_done#.<BR>">
> <CFELSE>
> Transfer failed!<BR>
> </CFIF>
>
> </CFLOOP>
>
> <CFFTP ACTION="CLOSE" STOPONERROR="NO" CONNECTION="half">
> <CFIF CFFTP.Succeeded>
> <CFSET message = message & "Connection to
>#half_ftpserver# closed.<BR>">
> <CFELSE>
> <CFSET message = message & "Error closing
>Connection to #half_ftpserver#.<BR>">
> </CFIF>
>
> <CFELSE>
>
> <CFSET message = message & "Failed to open FTP connection
>to #half_ftpserver#.<BR>">
>
> </CFIF>
>
></CFIF>
>
><CFOUTPUT><P>#message#</P></CFOUTPUT>
>
>
>>Hello All:
>>
>>ISSUE: CFFTP all .txt files in a given directory.
>>
>>I'm trying to have code that will FTP all the .txt files in a directory
>>to another server. Can anyone help me out here? I would also like to
>>know if the files names are in a date format can I perform a range and
>>have only certain files be selected for the ftp?
>>
>>Example of May 17, 2002 = 05172002.txt
>>
>>Sincerely,
>>James Blaha
>>
>><CFFTP CONNECTION="movefiles"
>>USERNAME="anonymous"
>>PASSWORD="guest@unknown"
>>SERVER="172.17.89.157"
>>ACTION="Open"
>>STOPONERROR="Yes">
>>
>><!---
>>Get a File
>>For the get function, both the remote file and the name it will have on
>>the local server must be specified. The transfer mode is set explicitly
>>here for clarity, but cfftp will usually make the right choice based on
>>file extension anyway (and its default list of extensions with which
>>ASCII mode should be used is easily changed). Call this code rget.cfm.
>>--->
>><!---
>><cfftp connection="movefiles" action="GetFile"
>>remotefile="untitled.txt"
>>localfile="C:\Inetpub\wwwroot\CFFTP\file_folder\untitled.txt"
>>transfermode="binary"
>>timeout="30" retrycount="3" stoponerror="no" failifexists="no">
>>--->
>><cfftp connection="movefiles" action="GetFile"
>>REMOTEFILE="/"
>>localfile="C:\Inetpub\wwwroot\CFFTP\file_folder"
>>transfermode="binary"
>>timeout="30" retrycount="3" stoponerror="no" failifexists="no">
>><!---
>>Delete a Local File
>>The command to delete a local file is actually a one-liner that's pulled
>>out into a separate file for clarity. The file parameter consists of the
>>path to the script (set by view.cfm), the directory below it that holds
>>these files, and the name of the file. Call this code ldel.cfm.
>>
>><cffile action="delete"
>>file="#scriptdir#/stuff/#mydel#">
>>--->
>><!---
>>Close a Remote Connection
>>If you don't close the connection, it will tie up resources of two
>>computers until the remote server eventually times it out. Call this
>>code rclose.cfm.
>>--->
>>
>><cfftp connection="movefiles" action="close">
>>
>>
>>
>><p>When this page is accesed the text files from "cfftp" are
>>tranfered
>>to "file_folder".</p>
>><p><CFFTP CONNECTION=FTP
>>USERNAME="anonymous"
>>PASSWORD="guest@unknown"
>>SERVER="172.17.89.157"
>>ACTION="Open"
>>STOPONERROR="Yes">
>><CFFTP CONNECTION=FTP
>>ACTION="GetCurrentDir"
>>STOPONERROR="Yes">
>></p><CFOUTPUT> FTP directory listing of #cfftp.returnvalue#.<p>
>></CFOUTPUT>
>>
>><CFOUTPUT>
>>Return is #cfftp.returnvalue#
>></CFOUTPUT><BR>
>>
>><CFFTP CONNECTION=FTP
>>ACTION="ListDir"
>>DIRECTORY="//file_folder"
>>NAME="ListFiles"
>>STOPONERROR="Yes">
>>
>><HR>
>><form name="ftpfiles" method="post" action="ftpfiles.cfm">
>><h3>FTP Directory Listing:</h3>
>><cftable query="ListFiles" HTMLTABLE>
>><cfcol header="<B>Name</B>" text="<B>Name:</B> #name#">
>><cfcol header="<B>Path</B>" text="<B>Path:</B> #path#">
>><cfcol header="<B>URL</B>" text="<B>URL:</B> #url#">
>><cfcol header="<B>Length</B>" text="<B>Length:</B> #length#">
>><cfcol header="<B>Date Formted</B>" text="<B>Date Formatted:</B>
>>#DateFormat(LastModified)#">
>><cfcol header="<B>IsDirectory</B>" text="<B>IsDirectory:</B> #isdirectory#">
>></cftable>
>>
>>
>>
>
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists