Last active
March 4, 2019 05:46
-
-
Save manashmandal/04774f2b689845494e63393897f62dd5 to your computer and use it in GitHub Desktop.
Batch Delete GitHub Forked Repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install tqdm and requests to run this script | |
import requests | |
from tqdm import tqdm | |
ACCESS_TOKEN = "ACCESS_TOKEN_WITH_DELETE_ACCESS" | |
USERNAME = "your-github-username" | |
LIST_REPOSITORY = "https://api.github.com/users/your-github-username/repos?page={}" | |
API_DELETE_REPO = "https://api.github.com/repos/your-github-username/{}" | |
repo_list = [] | |
for i in tqdm(range(1, 201)): | |
repositories = requests.get(LIST_REPOSITORY.format(i), auth=(USERNAME, ACCESS_TOKEN)).json() | |
filtered = [repo for repo in repositories if repo['fork'] == True] | |
repo_list.extend("".join(r['url'].split('/')[-1]) for r in filtered) | |
for repo in tqdm(repo_list): | |
requests.delete(API_DELETE_REPO.format(repo), auth=(USERNAME, ACCESS_TOKEN)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment