I need a powershell script which will delete all bin and obj folders in all the sub…
- User
I need a powershell script which will delete all bin and obj folders in all the sub directories starting from a root folder
- Assistant
You can use the following PowerShell script to delete all bin and obj folders in all subdirectories starting from a given root folder:
$rootFolder = "C:\YourRootFolder" #Replace with your root folder path Get-ChildItem -Path $rootFolder -Recurse -Force -Directory | ForEach-Object { if ($_.Name -eq "bin" -or $_.Name -eq "obj") { Write-Host "Deleting folder $($_.FullName)" Remove-Item -Path $_.FullName -Recurse -Force } }This script sets the
$rootFoldervariable to the path of your root folder. It then usesGet-ChildItemwith the-Recurseflag to find all directories inside the root folder, iterates over them usingForEach-Object, checks if the name of a directory is eitherbinorobjand, if it is, writes the target folder to the console and removes it usingRemove-Item.Remember to replace "C:\YourRootFolder" with the actual path to your root folder before executing the script.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.