Willi Kuhnis wrote:
> Hi Leigh,
> 
> thanks for the MSDOS Batch script.
> I tried it with Groovy for some hours, and I still think, it should be
> possible very easy, but I still couldnt make it running.
> 
> But with your DOS Batch it works very nice.
> I call it now with <exec> it it runs perfectly.
> 
> Thanks for your help !
> 
> 

I can't let a ugly (sorry Leigh, this is not your fault, I just don't
like dos) dos script win here ;-)

What about something like that:

<groovyScript>
  def nbFilesToKeep = 10
  def dir = new File(project.properties['resultFolder'])
  def files = dir.listFiles().toList()
  files.sort { it.name }
  if (files.size() > nbFilesToKeep)
  {
    def filesToDelete = files[0..(files.size() - nbFilesToKeep - 1)]
    def ant = new AntBuilder(project)
    filesToDelete.each {
      ant.delete(dir: it.absolutePath)
    }
  }
</groovyScript>

Cheers,
Marc.
-- 
Blog: http://mguillem.wordpress.com

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to