Skip to content

Instantly share code, notes, and snippets.

@2gn
Created November 19, 2022 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2gn/06bbd37ef834ac48db7faf2fd2935054 to your computer and use it in GitHub Desktop.
Save 2gn/06bbd37ef834ac48db7faf2fd2935054 to your computer and use it in GitHub Desktop.
clean-up your abandoned projects
from subprocess import getoutput, run
directory_structure = getoutput(["ls", "-l"]).splitlines()
items_to_be_removed = []
for file_or_directory in directory_structure:
if file_or_directory != "cleanup.py":
yesOrNo = input("Do you need this (y/n) : "+file_or_directory)
if yesOrNo == "n":
items_to_be_removed.append(file_or_directory)
print(items_to_be_removed)
if input("the items above will be removed. continue? (y/n) ") == "n":
raise SystemExit
for item in items_to_be_removed:
print("removing", item)
run(["rm", "-rf", item])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment