Files
PowerShellScripts/Git/FindGitRepos.ps1
T
farcasclaudiu a144ffc6e1 Init commit
Extremely needed script used to find and centralise git repos spread
inside my dev machine!
2017-01-17 21:07:29 +02:00

38 lines
1.1 KiB
PowerShell

Function GetGitRepos {
<#
usage:
'. .\FindGitRepos.ps1; GetGitRepos <start_search_path_optional>'
'. .\FindGitRepos.ps1; GetGitRepos'
arguments:
if <start_search_path_optional> is missing it will be considered current script folder
remarks:
I needed this script to find and centralise all git repos stored on my machine.
Now I have them all under control!
You can have them too!
#>
Write-Host "------------------------------------------"
if($args[0]){
$path = $args[0] + "*"
Write-Host "Search git repos in '$path'"
$Files = Get-ChildItem . -Path $path -Attributes Directory,Directory+Hidden -ErrorAction SilentlyContinue -Include ".git" -Recurse
}
else {
$path = $PSScriptRoot + "*"
Write-Host "Search git repos in local '$path'"
$Files = Get-ChildItem . -Attributes Directory,Directory+Hidden -ErrorAction SilentlyContinue -Include ".git" -Recurse
}
Write-Host "------------------------------------------"
if($Files.Count>0){
foreach ($File in $Files) {
write-host $($File)
}
}
else{
Write-Host "No git repos found"
}
Write-Host "------------------------------------------"
}