Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFFTP rename and remove by date?

Status
Not open for further replies.

JuanSanchez

Programmer
Oct 16, 2000
24
US
I curently trying to write a chunk of code that will look at all the files on a directory of my ftp server and rename anything that is 7 days old and then delete anything that is 21 days old.

This is what im fumbling with now I'm still working on the rename part of it right now....

<CFFTP CONNECTION=FTP
USERNAME=&quot;xxx&quot;
PASSWORD=&quot;xxx&quot;
SERVER=&quot;xxx&quot;
ACTION=&quot;Open&quot;
port=&quot;22&quot;
STOPONERROR=&quot;Yes&quot;>

<CFFTP CONNECTION=&quot;FTP&quot;
ACTION=&quot;listdir&quot;
DIRECTORY=&quot;/test/test1/test2&quot;
NAME=&quot;RDirectory&quot;
STOPONERROR=&quot;Yes&quot;>

<CFFTP CONNECTION=FTP
ACTION=&quot;GetCurrentDir&quot;
STOPONERROR=&quot;Yes&quot;>

<CFLOOP QUERY=&quot;rdirectory&quot;>
<cfquery datasource=&quot;crs2k1&quot; name=&quot;crs2k1&quot; username=&quot;xxx&quot; password=&quot;xxx&quot;>
select *
from userFriendly
where name = '#rdirectory.name#'
</cfquery>

<cfif #datediff(&quot;w&quot;, now(), rdirectory.lastmodified)# gte -21 >

<CFFTP CONNECTION=FTP
ACTION=&quot;rename&quot;
item=&quot;rdirectory.name&quot;
STOPONERROR=&quot;Yes&quot;>

</cfif>
</CFLOOP>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top