nmbl Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

cleanse - Remove bin/obj Folders

Overview

The cleanse command recursively removes all bin and obj folders from a directory tree. This is useful for cleaning up build artifacts, reducing disk space usage, and ensuring fresh builds. It’s particularly helpful when switching branches, troubleshooting build issues, or preparing a codebase for distribution.

Syntax

nmbl cleanse [Path] [options]

Arguments

  • Path - Root directory to clean (default: current directory)

Options

  • -y - Skip confirmation prompt and delete immediately

Output

Reports the number of folders deleted.

Examples

Clean Current Directory (With Confirmation)

nmbl cleanse

Prompts for confirmation before deleting folders.

Clean Specific Path Without Confirmation

nmbl cleanse ~/projects/MySolution -y

Immediately deletes all bin/obj folders under the specified path.

Clean Before Switching Branches

# Clean before branch switch
nmbl cleanse -y

# Switch branches
git checkout feature-branch

# Do a clean build
dotnet build

Clean Multiple Solutions

nmbl cleanse ~/projects/Solution1 -y
nmbl cleanse ~/projects/Solution2 -y
nmbl cleanse ~/projects/Solution3 -y

Use Cases

Troubleshooting Build Issues

# Clean all build artifacts
nmbl cleanse -y

# Rebuild from scratch
dotnet clean
dotnet restore
dotnet build

Build issues sometimes stem from stale artifacts. A full cleanse ensures a fresh start.

Reducing Disk Space

# See how much space you're using
du -sh ~/projects

# Clean all solutions
nmbl cleanse ~/projects -y

# Check space savings
du -sh ~/projects

Build artifacts can consume significant disk space, especially in large solutions.

Preparing for Git Operations

# Before committing or switching branches
nmbl cleanse -y

# Ensures build artifacts aren't accidentally committed
git status

CI/CD Scripts

# In a build script
nmbl cleanse /build/source -y
dotnet restore
dotnet build
dotnet test

Start CI builds with a clean slate.

End of Day Cleanup

# Clean up your workspace
nmbl cleanse ~/workspace -y

Free up disk space and ensure tomorrow’s builds are fresh.

What Gets Deleted

The command removes:

  • All bin folders and their contents
  • All obj folders and their contents
  • These folders are recursively found in the entire directory tree

Safety Features

  • Confirmation prompt - By default, asks for confirmation before deletion
  • Selective deletion - Only removes bin and obj folders, nothing else
  • Progress reporting - Shows how many folders were deleted

Tips

Create an Alias

# Add to your shell profile
alias clean='nmbl cleanse -y'

# Use it
clean

Combine with Git Clean

# Remove build artifacts
nmbl cleanse -y

# Remove untracked files
git clean -fdx -e .vs -e .vscode

Complete cleanup including git ignored files.

Weekly Maintenance

# Add to cron or scheduled task
nmbl cleanse ~/projects -y

Automatically clean up build artifacts weekly.