Last active
June 20, 2022 13:05
-
-
Save alinefr/9cc54871d439ac96aff2 to your computer and use it in GitHub Desktop.
Simple python script to delete multiple github repositories.
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
import os | |
import requests | |
token = '' # token needs delete_repo permission | |
organization = '' # or user | |
url = 'https://api.github.com/repos/{}'.format(organization) | |
headers = {'Accept': 'application/vnd.github.v3+json', | |
'Authorization': 'token {}'.format(token)} | |
lines = [line.strip() for line in open('todelete.txt')] # todelete.txt is a txt with repository names. One per line. | |
for repo in lines: | |
print os.path.join(url, repo) | |
myrequest = requests.delete(os.path.join(url, repo), headers=headers) | |
print myrequest.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment