Skip to content

Instantly share code, notes, and snippets.

@zippy1981
Created February 23, 2011 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zippy1981/841433 to your computer and use it in GitHub Desktop.
Save zippy1981/841433 to your computer and use it in GitHub Desktop.
Using powershell to list particular files in svn.
Add-Type -AssemblyName "System.Web"
# Powershell function to iterate through all the branches of a
# Visual Studio Solution in SVN, and return the file names in particular subfolders of the database project
# Assumes the command line svn client is in the system path
function Get-ReleaseScripts (
[string] $branchRoot,
[string] $subProject,
[string[]] $scriptFolders = ('Ad Hoc Scripts', 'Release Scripts')
) {
[string[]] $branches = svn ls $branchRoot;
foreach ($branch in $branches) {
[string] $branchPath = $branchRoot + '/' + $branch + $subProject;
foreach ($scriptFolder in $scriptFolders) {
[string] $scriptPath = $branchPath + [Web.HttpUtility]::UrlPathEncode($scriptFolder);
[string[]] $scriptFiles = svn ls $scriptPath 2> $null;
"`t$scriptFolder/";
if ($scriptFiles.length -gt 0) {
foreach ($file in $scriptFiles) { "`t`t$file" }
"`t`t- $($scriptFiles.length) files";
} else {
"`t`tNo scripts found"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment