How to create a workflow to delete all documents from a document library?
Last Update: December 21, 2018
Apply for: SPARK Workflow for SharePoint 2013/2016 and Office 365
Suppose you have a document library named "DocLib1" and you want create a workflow to delete all documents from this library.
Here are the steps on how to do that.
- Create a new list workflow. For more details on how to create a list workflow, refer to
Create a list workflow use case.
- Drag "For Each" and "Delete Item" activities onto the workflow canvas and drop it onto a design node as follows:

- Configure the "For Each" activity as follows:
Note: A workflow variable of type integer should be created to store the value in when looping through each value in the library. - Configure the "Delete Item" activity as follows:

- Publish the workflow by clicking on the
Publish button in the workflow ribbon.
- Now go to "DocLib1" document library and run the workflow. For more details on how to run a list workflow, refer to
Run a list workflow use case.
- After completing running the workflow, you will see that all documents have been deleted from "DocLib1".