You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "David F. White" <dw...@opentext.com> on 2004/04/16 16:48:29 UTC

FTP Task - Delete Files Based on a Time Stamp?

Is the following scenario possible using the FTP task?  When our daily 
builds complete we FTP them to another server.  I would like to use the FTP 
task to delete files on the server that are older than a specified date 
(e.g. 7 days prior to the current date).  I hoped I could use the "date" 
selector within the "fileset" task to accomplish this operation.  The 
following code is from the build script I wrote:

<target name="getBuildDate">
	<tstamp>
		<format property="buildDate" pattern="MM/dd/yyyy hh:mm aa" offset="-7" 
unit="day" />
	</tstamp>
</target>	

<target name="forms" if="CHECK_FORMS" depends="getBuildDate">		
	<echo message="Deleting FTP Forms builds before ${buildDate}" />
	<ftp action="del" server="${FTP_SERVER}" userid="${FTP_USER}" 
password="${FTP_PASSWORD}" remotedir="${FTP_FORMS_LOCATION}" verbose="true">
		<fileset includes="**/*">
			<date datetime="${buildDate}" when="before"/>
		</fileset>							
	</ftp> 	
</target>

Unfortunately, the FTP task seems to be ignoring the "date" selector.  The 
FTP task deletes all the files regardless of the designated time stamp.

Is this a bug in Ant?  Am I trying to do something the FTP task doesn't 
support?  I know the FTP task ignores other "fileset" attributes such as 
"dir" when it is used within the context of the "FTP" task.

Any help toward solving this problem is greatly appreciated.

Thanks...

Dave White


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org