Skip to content

Instantly share code, notes, and snippets.

@alinefr
Last active June 20, 2022 13:05
Show Gist options
  • Save alinefr/9cc54871d439ac96aff2 to your computer and use it in GitHub Desktop.
Save alinefr/9cc54871d439ac96aff2 to your computer and use it in GitHub Desktop.
Simple python script to delete multiple github repositories.
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