JuanSanchez
Programmer
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="xxx"
PASSWORD="xxx"
SERVER="xxx"
ACTION="Open"
port="22"
STOPONERROR="Yes">
<CFFTP CONNECTION="FTP"
ACTION="listdir"
DIRECTORY="/test/test1/test2"
NAME="RDirectory"
STOPONERROR="Yes">
<CFFTP CONNECTION=FTP
ACTION="GetCurrentDir"
STOPONERROR="Yes">
<CFLOOP QUERY="rdirectory">
<cfquery datasource="crs2k1" name="crs2k1" username="xxx" password="xxx">
select *
from userFriendly
where name = '#rdirectory.name#'
</cfquery>
<cfif #datediff("w", now(), rdirectory.lastmodified)# gte -21 >
<CFFTP CONNECTION=FTP
ACTION="rename"
item="rdirectory.name"
STOPONERROR="Yes">
</cfif>
</CFLOOP>
This is what im fumbling with now I'm still working on the rename part of it right now....
<CFFTP CONNECTION=FTP
USERNAME="xxx"
PASSWORD="xxx"
SERVER="xxx"
ACTION="Open"
port="22"
STOPONERROR="Yes">
<CFFTP CONNECTION="FTP"
ACTION="listdir"
DIRECTORY="/test/test1/test2"
NAME="RDirectory"
STOPONERROR="Yes">
<CFFTP CONNECTION=FTP
ACTION="GetCurrentDir"
STOPONERROR="Yes">
<CFLOOP QUERY="rdirectory">
<cfquery datasource="crs2k1" name="crs2k1" username="xxx" password="xxx">
select *
from userFriendly
where name = '#rdirectory.name#'
</cfquery>
<cfif #datediff("w", now(), rdirectory.lastmodified)# gte -21 >
<CFFTP CONNECTION=FTP
ACTION="rename"
item="rdirectory.name"
STOPONERROR="Yes">
</cfif>
</CFLOOP>