IF this a consistent directory tree? If so, just exclude the directories
from the delete. If not I think you should be able to use a foreach to
loop over a fileset and delete each individual files. But, I don't know
how good the performance on this will be.

 

BOb

 

________________________________

From: Parrish, Ken [mailto:kparr...@gomez.com] 
Sent: Tuesday, January 06, 2009 10:34 AM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] Delete files but preserve directory tree

 

I am trying to write a Nant task which, given the pathname of a
directory, will recursively remove all the files at all levels in the
directory tree, but will NOT delete any of the directories themselves.

 

This is needed so that we can 'purge' a deployment web site, but
preserve the directory tree and configuration files, thus preserving
various file system and web server permissions and attributes assigned
to various nodes in the directory tree.

 

I was hoping to do this with a single <delete> task, but have been
unsuccessful in my attempts to create a <fileset> element which behaves
properly.  I tried using <include name="**" /> but that causes all the
subdirectory nodes to be deleted as well.  For example:

 

 

           <delete>
                 <fileset basedir="${PurgeDeploymentDirectory_dir}">
                       <include name="**" />
                 </fileset>
           </delete>



Does anyone have any ideas how to approach this problem?  Should I write
this as a task that recursive walks the directory tree?

 

Thanks,

 

Ken Parrish

Gomez, Inc.

 

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to