# Delete multiple folders

**URL:** https://www.finalbuilder.com/forums/t/delete-multiple-folders/5302
**Category:** Discussion
**Created:** [January 13, 2015, 6:21am UTC](https://www.finalbuilder.com/forums/t/delete-multiple-folders/5302 "2015-01-13T06:21:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kay.zumbusch](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@kay.zumbusch](https://www.finalbuilder.com/forums/u/kay.zumbusch)
#### Post date: [January 13, 2015, 6:21am UTC](https://www.finalbuilder.com/forums/t/delete-multiple-folders/5302/1 "2015-01-13T06:21:23Z")

</div>

Hi,  
  
in addition to storing the installer binaries from our builds as artifacts in Continua we copy the installer files to a network share. Every build is copied to a seperate directory on the network share. At the moment I regularly check the network share for old build versions and remove them manually. I’d like to add a final step to our build process that removes all directories from the network share but leaves the directory of the current build untouched.  
  
Is there a way to build a list of existing directories and remove all directories from this list? In that case I would fill this list before I create the new directory and remove the old directories after the new files were copied. I remember using a similar way in FinalBuilder to remove files.  
  
Regards  
  
Kay Zumbusch

---

<div class="post-metadata">

### Author: ![rlove](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/rlove/32/27_2.png) [@rlove](https://www.finalbuilder.com/forums/u/rlove)
#### Post date: [January 13, 2015, 7:57am UTC](https://www.finalbuilder.com/forums/t/delete-multiple-folders/5302/2 "2015-01-13T07:57:58Z")

</div>

We needed something similar but our requirement was to leave the last 5 builds on the network share. &nbsp;&nbsp;  
  
We could not find anything in the product. &nbsp; We could have written a FinalBuilder script and call it, but instead we wrote a Delphi Program that is called at the end of the build.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [January 14, 2015, 1:28am UTC](https://www.finalbuilder.com/forums/t/delete-multiple-folders/5302/3 "2015-01-14T01:28:26Z")

</div>

Hi Kay,  
  
There is no way to build up a list of directories in Continua, although there are a Delete and Delete Directory actions which you could use to delete existing files&nbsp;at the start of the build.&nbsp;The Delete action allows you to specify include and exclude patterns. &nbsp;If the folders are named using build number, you can use $Build.BuildNumber$ in these patterns or use a variable and Set Variable actions&nbsp;to decrement the value if, for example, you want to exclude build number minus one.  
  
We also recommend using a Finalbuilder action for this type of task.&nbsp;Note that Continua is designed &nbsp;to work with FinalBuilder not replace it.   
  
You can pass $Build.BuildNumber$ to FinalBuilder&nbsp;as a variable and then iterate back through the build numbers defining the folders to want to delete using variables and passing these to a Delete Directory action. You can also build up a list of directories to delete using FileSets within Finalbuilder with pattern and/or date-time filters.   
  
Alternatively you can delete folders based on date using an Execute Program to&nbsp;call other programs&nbsp;such as Robocop.
