# How to Create a Script to "Bulk Remove" from a Group?

**URL:** <https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614>\
**Category:** Product Support\
**Created:** [January 30, 2017, 8:45pm UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614 "2017-01-30T20:45:36Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Selk68](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selk68/32/67080_2.png) [@Selk68](https://meta.discourse.org/u/Selk68)\
**Post date:** [January 30, 2017, 8:45pm UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/1 "2017-01-30T20:45:36Z")

</div>

Continuing the discussion from [Bulk add to Group](https://meta.discourse.org/t/bulk-add-to-group/34979/15):

> [@Falco](#):
>
> I took a step back and rewrote everything in a nice script that reads from a database using sequel and writes to Discourse with the api, adding and removing users everyday at midnight. Put it on Jenkins and never looked back.

@Falco and all, this is something that I would like to be able to do on the forum that I help run.

We have one category for “Members Only” - that is restricted to only our paid/active members - that I am able to import a list of users who currently have active accounts in our Active Directory through the Web Interface; however, there is no easy way to do a bulk remove of members who are no longer active from the group using the Web Interface.

I do have access to the server side and one of our admins already has a script to export the active accounts to a CSV file that includes the e-mail addresses of all currently active members; however, I do not know how to create a script that would remove all members from the restricted group on our forum, then add only the currently active members back to it (_which sounds like basically what you are doing…_). This is something that I would like to have done daily, as mentioned in the post quoted above.

Can you give me any pointers, please?

---

_[View the full topic](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614)._
