Purger


Simple utility script I made for working with Xamarin and Visual Studio Mac. When we change branches often, and sometimes the project starts showing strange and unexpected behaviours.

Most of the time, the most simple way to deal with this is to delete all the bin and obj folders from the project and rebuild. It is annoying an time consuming for our project as we have multiple shared libraries, so I wrote a script that will crawl through the directory it’s run from and delete any folder called “bin” or “obj”. I think this simple script has saved me a few hours over the years.

 
#!/usr/bin/env python
import os, sys, shutil

if __name__=="__main__":
    rootDir = os.getcwd()
    for dirName, subdirList, fileList in os.walk(rootDir):
        if ("obj" == os.path.basename(os.path.normpath(dirName))):
            print("Deleting: " + dirName)
            shutil.rmtree(dirName)
        elif ("bin" == os.path.basename(os.path.normpath(dirName))):
            print("Deleting: " + dirName)
            shutil.rmtree(dirName)