Skip to content

Instantly share code, notes, and snippets.

@jrich523
Last active August 23, 2019 19:30
Show Gist options
  • Save jrich523/77aae37d970bbdaa0e2405d956ff5ee6 to your computer and use it in GitHub Desktop.
Save jrich523/77aae37d970bbdaa0e2405d956ff5ee6 to your computer and use it in GitHub Desktop.
Find all projects within a folder (recursive)
function find-Projects {
param(
$root='D:\Repos',
$depth = 5)
$projectTypes = @(".git",".vscode")
## is this folder a project?
if(ls $root -Directory -Name -Force | ? { $projectTypes -contains $_})
{
return $root
}
if($depth -gt 0){
$folders = ls -Path $root -Directory
foreach($folder in $folders)
{
find-Projects $folder.fullname $depth-1
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment